How long should CLAUDE.md be?
Under 200 lines per file. That is Anthropic's own guidance in the Claude Code memory docs: "target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence."
Two details matter. First, @path imports do not save anything: the docs note that imported files also load at launch, so splitting a long file into imports keeps the same cost. Second, every CLAUDE.md from the project root up through parent folders loads at launch, so a long file in a parent folder is paid for in every repo below it.
Line count is a proxy for the real problem. A short file of vague advice ("write clean code") helps less than a short file of specific facts: the exact command, the exact path, the exact rule. Specific beats long.
The same applies to AGENTS.md. Recent versions of Claude Code read AGENTS.md when a folder has no CLAUDE.md, and you can import it with @AGENTS.md or symlink it. A long AGENTS.md has the same problem in every agent that reads it.
| File | When it loads | Counts against context |
|---|---|---|
| CLAUDE.md in the project root and parent folders | At launch | Always |
| @path imports inside CLAUDE.md | At launch, up to four hops deep | Always |
| CLAUDE.md in a subfolder | When Claude reads files in that folder | Only then |
| .claude/rules/*.md without paths | At launch | Always |
| .claude/rules/*.md with paths | When Claude reads, writes or edits a matching file | Only then |
| Skills (.claude/skills/<name>/SKILL.md) | Name and description at launch, body when invoked | Mostly only when used |
| Auto memory (MEMORY.md) | First 200 lines or 25KB at launch | Always, capped |
sourcesClaude Code docs: memory
Why does Claude ignore parts of my CLAUDE.md?
Because CLAUDE.md is context, not configuration. Anthropic's docs say Claude treats these files "as context, not enforced configuration". The longer and vaguer the file, the more each line competes with the code and the task in front of the model.
The usual causes are the same in every long file: rules that only apply to one folder, multi-step procedures that matter once a week, duplicates that drifted apart, and contradictions. On contradictions, the docs say Claude may pick one arbitrarily.
Thoughtworks placed "agent instruction bloat" in the Caution ring of its Technology Radar (Vol. 34, April 2026), recommending teams "be deliberate and selective with instructions" and continuously refine toward a minimal, coherent set.
- Symptom: Claude follows a rule in one session and not the next. Cause: the rule competes with too much else.
- Symptom: Claude follows the wrong one of two rules. Cause: a contradiction, often an old line nobody deleted.
- Symptom: Claude forgets a rule after a long session. Cause: it lived in a nested file or chat, not the root CLAUDE.md, which is re-read after /compact.
sourcesClaude Code docs: memoryThoughtworks Radar: agent instruction bloat
in the prompt read by the AI
Shipped. Nobody said yes.
as a gate checked by the engine
Waiting for you.
What should stay in CLAUDE.md, and what should move?
Keep what Claude needs on almost every task, in one line each. Move everything else to the place that loads it only when it is needed, or that enforces it instead of asking. Anthropic's guidance: "If an entry is a multi-step procedure or only matters for one part of the codebase, move it to a skill or a path-scoped rule."
A quick test for each line: would Claude make a mistake on most tasks without it? If not, it does not belong in the always-loaded file. If the mistake would be costly, it belongs in something enforced, not in a sentence.
| Kind of line | Example | Where it goes |
|---|---|---|
| Fact used on most tasks | Test command, folder layout, language | Stays in CLAUDE.md |
| Rule for one folder | How API handlers validate input | .claude/rules/api.md with paths |
| Multi-step procedure | How to cut a release | A skill, run with /release |
| Something that must never happen | Never read .env, never force push | Permission deny rules or a hook |
| Something that must always happen first | Tests pass before a push | A PreToolUse hook |
| A role with its own focus | Security reviewer | A subagent in .claude/agents |
| A team process with sign-offs | Fix, review, approve, ship | A workflow engine, such as ConvOps |
| Long background reading | Architecture notes | A doc Claude reads when needed, not an import |
sourcesClaude Code docs: memoryClaude Code docs: skills
How do I shorten a long CLAUDE.md step by step?
Measure, sort every line by where it belongs, move it, then check what loads. The commands below are all built into Claude Code.
- 1
Measure
Count the lines in every instruction file Claude loads, then open /context in Claude Code to see the memory files and their share of the window.
wc -l CLAUDE.md AGENTS.md .claude/rules/*.md 2>/dev/null - 2
Run the prompt audit
In recent versions of Claude Code, /doctor prompt-audit reviews your instruction files. Use /memory to open and edit them.
/doctor prompt-audit - 3
Move folder rules to path-scoped rules
A rule with paths frontmatter loads only when Claude touches a matching file.
--- paths: - "src/api/**/*.ts" --- # API handler rules - Validate input with the zod schema next to the handler. - Return errors as { code, message }. Never leak stack traces. - Every new route gets a test in tests/api. - 4
Move procedures to skills
Each multi-step procedure becomes .claude/skills/<name>/SKILL.md. Only its name and description load until you run it.
mkdir -p .claude/skills/release && $EDITOR .claude/skills/release/SKILL.md - 5
Turn "never" lines into deny rules
A deny rule is enforced; a sentence is not. Put it in .claude/settings.json and delete the sentence.
{ "permissions": { "deny": ["Read(./.env)", "Read(./secrets/**)", "Bash(git push --force *)"] } } - 6
Delete duplicates and contradictions
Search for the same topic in several places and keep one line. If two lines disagree, decide, and delete the loser.
- 7
Check the result
Start a new session, run /context again, and give Claude a small task in each area you moved. Confirm that the path rules and skills load when they should, and only then.
sourcesClaude Code docs: memoryClaude Code docs: skillsClaude Code docs: permissions
What does a short CLAUDE.md look like?
Commands, layout, a few conventions, and pointers to where the rest lives. The example below is 19 lines. Everything that used to follow it now loads only when it applies.
Notice what is missing: no tone advice, no history of past decisions, no procedure. Decisions and their reasons belong in a memory store or the commit history, where they can be found when they are relevant.
# Project: billing-api
## Commands
- Install: pnpm install
- Test: pnpm test (must pass before any commit)
- Lint: pnpm lint --fix
## Layout
- src/api: HTTP handlers. src/domain: pure logic, no I/O.
- Migrations in db/migrations, one file per change.
## Conventions
- TypeScript strict. No default exports.
- Money is integer cents, never floats.
## More
- API rules load from .claude/rules/api.md when you edit src/api.
- Release steps: run /release.
- Architecture notes: docs/architecture.md (read it when needed).Where should a multi-step team process live instead?
In a workflow engine, not in any instruction file (how to make Claude Code follow a process compares the options). A process with sign-offs, branches and several people is often one of the largest blocks in a long CLAUDE.md, and it is also the part the model is most likely to compress or skip.
ConvOps holds that process as a graph of workflows and serves it to Claude Code over MCP one step at a time, so only the active step is in context. Rules that apply to a kind of work become policies attached to the workflow and arrive inside the step they govern. Decisions made along the way are stored as memories in the brain, so they do not have to be appended to CLAUDE.md to survive the session.
| Was in CLAUDE.md | In ConvOps |
|---|---|
| "Always do A, then B, then ask me before C" | A workflow: the engine holds the order and a gate on C |
| "For content work, cite every claim" | A policy, delivered inside the active step |
| "Remember we chose Postgres over Mongo because..." | A memory, recalled when it is relevant |
| The same rules copied into AGENTS.md and .cursorrules | One definition, used by any MCP client |
What is the checklist for keeping it short?
Review it like code: on every change, and on a schedule. Use /init for a first draft, then prune it like any other file.
- Under 200 lines per file, with no imports used as a workaround.
- Every line is a fact or a rule Claude needs on most tasks.
- No procedure longer than three lines. It is a skill.
- No rule that only applies to one folder. It is a path-scoped rule.
- No "never" or "always" sentence that a deny rule or hook can enforce.
- No two lines on the same topic.
Frequently asked questions
Is there a hard size limit for CLAUDE.md?
Anthropic does not document a hard cap for CLAUDE.md. It recommends under 200 lines per file because longer files consume more context and reduce adherence. Auto memory is different: only its first 200 lines or 25KB load at launch.
Do @imports make a long CLAUDE.md cheaper?
No. Imported files also load at launch, so they cost the same context. Imports help organise text. To load something only when needed, use a path-scoped rule in .claude/rules or a skill.
Does Claude Code read AGENTS.md?
Yes. Recent versions read it when the folder has no CLAUDE.md. If you have both, import AGENTS.md from CLAUDE.md with @AGENTS.md or symlink it, so there is one source.
Why does Claude forget a rule after /compact?
The project-root CLAUDE.md is re-read from disk after /compact. Rules given only in chat are not. Nested CLAUDE.md files and path rules load again when Claude next reads a matching file.
Should I put "never do X" in CLAUDE.md?
Put it in a permission deny rule or a PreToolUse hook instead. Anthropic's docs say that to block an action regardless of what Claude decides, you use a hook. A sentence in CLAUDE.md is guidance.
How do I see what Claude Code actually loaded?
Run /context to see the context window, including the memory files. Run /memory to open and edit them. In recent versions, /doctor prompt-audit reviews your instruction files.