Minideas

Idea 4 of 15 · Claude Code

Rules it follows

Project instructions in CLAUDE.md, permission modes and rules for what it may do, and hooks for what must always happen.

CLAUDE.md• tests: npm test• use TypeScript• don’t edit /legacyshort: followedlong: skimmedread at the start of every session
1 / 4

CLAUDE.md: project instructions

CLAUDE.md in your project root is loaded into every session: how to run the tests, team conventions, folders not to touch. Run /init and Claude drafts one from your codebase. Keep it short: it costs context every time, and a long file is followed less reliably.

modes, switched with Shift+Tabdefaultaccept editsplanauto.claude/settings.jsonallownpm testaskgit pushdenyread .envmodes set the default; rules set exceptions per command
2 / 4

Permission modes and rules

By default, Claude asks before editing files or running commands. Accept-edits mode lets it edit without asking; in auto mode, a safety check reviews each action for you. Rules in .claude/settings.json go further: let npm test run without asking, always ask before git push, never allow reading .env.

Claude…eventthe hook…edits cart.jsPostToolUseformats itgit push --forcePreToolUseblocks itsays “Done!”Stoptests fail:keep goingClaude Code runs them every time, whatever the model decides
3 / 4

Hooks: rules it can’t skip

A line in CLAUDE.md is a request, and requests get missed. A hook is a shell command that Claude Code itself runs at a set moment, every time: before a tool runs (it can block the call), after an edit, or when Claude wants to stop.

.claude/settings.json"hooks": {"PostToolUse": [{"matcher": "Edit|Write","hooks": [{ "type": "command","command": "npx prettier --write …" }]}]}eventwhich toolscommand to run
4 / 4

Add a hook

Hooks live in .claude/settings.json under hooks: an event, a matcher for which tools, and the command to run. This one formats every file Claude edits. A command that exits with code 2 blocks the action and tells Claude why. Type /hooks to list yours, or ask Claude to write one.

Swipe the card, or use the arrow keys.

Go deeper

Each card stack gives you the idea. These open resources go into the detail.

Notes on the Claude Partner Network learning path on Anthropic Academy.