Guide
CLAUDE.md best practices: what to keep, cut, and move
Updated 2026-11-14
Claude Code loads CLAUDE.md into every session in the project. That makes it the cheapest place for instructions that should always hold, and an expensive place for anything else, because every line rides along on every turn. The rule of thumb: keep what the agent needs on every task, and move everything else somewhere it can be read on demand.
What belongs in CLAUDE.md
- The exact commands to install, test, lint, and build, with a short note on any that must pass before a commit.
- Structure that is not obvious from the folder names: where the real entry point is, which package owns what.
- Rules the agent would otherwise break: a privacy invariant, a style rule the linter does not catch, an action that needs your approval first.
- Pointers, not payloads. One line saying where the design notes live beats pasting them in.
A CLAUDE.md template
# Project name
One sentence: what this is and who uses it.
## Commands
npm install
npm test # must pass before every commit
npm run lint
npm run build
## Structure
- src/server/ API routes; all database access lives here
- src/web/ UI; never imports from src/server directly
## Rules
- Never commit .env files. New env vars go in .env.example.
- Ask before running migrations.
## More context
- Architecture decisions: docs/DECISIONS.md What to cut or move
- Dated status and changelogs. "As of last week" notes go
stale and cost tokens on every turn. Move them to
docs/. - Sections duplicated between your global
~/.claude/CLAUDE.mdand the project file. Keep one copy. - Paragraphs about a single project sitting in the global file. Move them into that project's own CLAUDE.md.
- Generic advice the model already follows, such as "write clean code".
Global versus project CLAUDE.md
~/.claude/CLAUDE.md loads in every project you open.
./CLAUDE.md at the repo root loads for that project. Lines of
the form @path/to/file.md import another file, and imported
files are loaded too, so the real per-turn weight is the file plus
everything it imports. Put personal preferences in the global file and
project facts in the project file.
Measure it instead of guessing
The free audit scores your CLAUDE.md as one of its six setup pillars. The
paid costclaw optimize goes a step further: it scans each
repo for its real commands, stack, and layout, writes a CLAUDE.md draft
from that, measures the global file plus its imports, and marks the lines
of your existing file as keep, remove, move, or add, with a reason for
each mark. It is a draft for you or your
own Claude Code to review, not a rewrite applied behind your back, and
nothing is uploaded.