Claude Code

Configuration

CLAUDE.md, hooks, permissions, settings, cost management, and auto memory. Everything that makes Claude Code behave consistently across sessions and across your team.


CLAUDE.md in depth

CLAUDE.md is a markdown file that gives Claude persistent instructions about your project. Without it, Claude guesses your conventions anew every session. With it, Claude starts every session knowing your stack, your style, your commands, and your architectural decisions.

The loading hierarchy

CLAUDE.md files load in a specific priority order. Higher priority files override lower ones.

1. Managed policy /Library/Application Support/ClaudeCode/CLAUDE.md 2. Project (shared) ./CLAUDE.md or ./.claude/CLAUDE.md 3. User (all projects) ~/.claude/CLAUDE.md 4. Local project (personal) ./CLAUDE.local.md (gitignored) 5. Nested (on-demand) ./src/api/CLAUDE.md (loads when reading that dir) highest lowest

Level 1 overrides everything. Level 5 loads only when Claude reads files in that directory.

Most people only need two: the project-level CLAUDE.md (checked into git, shared with the team) and CLAUDE.local.md (personal, not in git).

What to put in it

Put in CLAUDE.mdDo not put in CLAUDE.md
Commands Claude cannot guess (npm test, npm run lint)Standard conventions Claude already follows (semicolons in JS)
Style rules that differ from defaults (2-space indent, ES modules)Detailed API docs (link to them instead)
Architecture decisions (routes live in /src/api/, tests next to source)Information that changes weekly (sprint priorities)
Common gotchas (the build requires Node 20, not 18)Long paragraphs of explanation (bullets are better)
Git conventions (branch off main, imperative commit messages)Rules Claude already gets from the code itself

Target: under 200 lines. If your CLAUDE.md is longer, Claude starts ignoring parts of it. Ruthlessly prune.

File imports

CLAUDE.md can reference other files using @path/to/file. The referenced file is embedded into context at startup:

CLAUDE.md with imports# Our project See @README.md for an overview. See @package.json for available npm commands. # Git workflow @docs/git-instructions.md # Architecture @docs/architecture.md

This keeps CLAUDE.md short while still giving Claude access to detailed reference material.


Hooks

Hooks are scripts that run at specific points in Claude Code's workflow. Unlike CLAUDE.md (which is advisory), hooks are deterministic: they guarantee that something happens every time a trigger fires.

The most useful hooks

settings.json hook examples
// Block any command containing "rm -rf"
{
"hooks": [
{
"hookName": "PreToolUse",
"matchOn": { "toolName": "Bash" },
"if": "Bash(rm -rf *)",
"type": "command",
"handler": "deny"
},
// Run the linter after every file edit
{
"hookName": "PostToolUse",
"matchOn": { "toolName": "Edit" },
"type": "command",
"handler": "npm run lint --fix"
},
// Auto-approve test commands
{
"hookName": "PreToolUse",
"matchOn": { "toolName": "Bash" },
"if": "Bash(npm test*)",
"type": "command",
"handler": "allow"
}
]
}

When to use hooks vs CLAUDE.md

Use hooks whenUse CLAUDE.md when
The action must always happen (lint after edit)The instruction is a preference (voice, style)
You need to block dangerous commands (rm -rf)You want Claude to know about conventions
You want to auto-approve safe operations (npm test)You want Claude to follow a workflow
You need external verification (send a webhook)You want to provide reference material

Auto mode

Auto mode lets Claude execute actions without asking for permission, with a background safety classifier checking each action before it runs.

Auto mode requirements

What auto mode blocks by default

What auto mode allows by default

If the classifier blocks three consecutive actions or twenty total in one session, auto mode pauses and resumes normal permission prompting.


The .claude/ directory

The .claude/ directory at your project root is where settings, rules, skills, agents, and commands live.

Directory structureproject/ .claude/ settings.json Shared project settings (checked in) settings.local.json Personal settings (not in git) CLAUDE.md Project instructions (checked in) CLAUDE.local.md Personal instructions (not in git) rules/ Scoped instructions by topic or file type testing.md api-design.md skills/ Reusable workflow definitions fix-issue/ SKILL.md agents/ Subagent definitions security-reviewer.md commands/ Custom slash commands CLAUDE.md Project root instructions (checked in) CLAUDE.local.md Local overrides (not in git)

Cost management

Claude Code uses your Anthropic API allocation. Complex tasks use more tokens than simple chats. A few levers for keeping costs predictable:

Rule of thumb: start with Sonnet (the default) for everything. Only use Opus when Sonnet has already failed on the same task. Use Haiku for bulk scripted operations where "good enough" is the standard.


Auto memory

Claude automatically saves notes about your project to ~/.claude/projects/<project>/memory/MEMORY.md. Build commands it discovers, debugging patterns, code style preferences, workflow habits, architecture notes. The first 200 lines load at the start of every session.

This is separate from CLAUDE.md. CLAUDE.md is what you write deliberately. Auto memory is what Claude learns by working with you. Both load at startup, both persist across sessions.

If auto memory is making mistakes (saving something wrong), you can edit MEMORY.md directly or disable it with autoMemoryEnabled: false in settings.json.


Configuration is what makes Claude Code go from "it works sometimes" to "it works the way I expect, every time". Start with a CLAUDE.md. Add hooks when you notice a thing that should always happen. Graduate to auto mode when the permission prompts slow you down more than they protect you.

Next: IDE integration for VS Code and JetBrains. Or go back to the Claude Code overview.