Project instructions in CLAUDE.md, permission modes and rules for what it may do, and hooks for what must always happen.
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.
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.
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.
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.