CLAUDE.md: presence matters, formatting may not
A 1,650-session study found CLAUDE.md length, position, nesting and self-contradiction had no measurable effect on adherence; only presence did (0% to 68%). The docs say the opposite, so treat both as unproven and restate the rule in your prompt when editing or late in a session.
Reported by people who use Claude Code heavily. We have not reproduced it, and it may be version-specific or plain wrong.
What this costs you if it is wrong
This rests on a blog's summary of a third-party study that has not been independently reproduced, and it contradicts the official docs on three points. Do not read it as "CLAUDE.md length is free" — a long file still consumes context tokens in every session and every subagent that loads it, which is a real cost the study never measured. If you delete your file's structure on the strength of this and adherence gets worse, you have no way to attribute the regression. The safe action here is the additive one (restate the rule in your prompt), not the subtractive one (stop maintaining the file).
You are editing CLAUDE.md for the fourth time this month. You moved the important rule to the top. You split it into a nested per-directory file. You cut the file to 80 lines. Claude still skipped it on the last refactor. The implicit theory behind all four edits is that adherence is a formatting problem — and there is now a measurement that says it probably is not.
What the measurement reports
Before the numbers, the chain of custody, because it changes how you should read them. Nobody in this repo has run this. What follows is a blog post summarizing a preprint that was not read directly and whose identifier could not be confirmed. Every figure below is reported, not reproduced.
With that stated: Damon McMillan's study, as written up by Alex Dunlop, is said to have run 1,650 Claude Code sessions across two real TypeScript codebases on Sonnet 4.6, checking one mechanically verifiable rule (an annotation on every function) across 16,050 functions. The variables were manipulated deliberately, one at a time.
| Variable tested | Levels | Reported effect on adherence |
|---|---|---|
| File exists at all | none vs. any | 0% → ~68% |
| File length | 25 / 100 / 250 / 500 lines | none significant |
| Rule position in file | top / middle / bottom | none significant |
| One root file vs. nested per-directory | 1 file vs. many | none significant |
| Injected self-contradiction | clean vs. contradictory | none significant |
| Task type | writing new code vs. editing existing | 71.3% vs. 45.1% — a 26-point gap |
| Session length | functions written so far | ~5.6% lower odds per additional function |
The two rows in bold are the only ones that moved. Everything you have been tuning is in the rows that did not.
The docs say something different
This is not a gap in the documentation. It is a head-on conflict, and you should know which pages you are contradicting before you act on it.
memory.md— "target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence," and later, "Shorter files produce better adherence."memory.mdagain, on consistency — "if two rules contradict each other, Claude may pick one arbitrarily."debug-your-config.md— adherence drops "when two files give conflicting direction, or when the file has grown long enough that individual rules get less attention."claude-directory.mdrepeats the 200-line target in its inline tips.
So the docs claim length and contradiction both hurt; the study reports neither did.
What both sides actually agree on
The two findings that survived the study are the ones the docs also gesture at, from a different direction:
- Decay over a session.
best-practices.mdsays outright that as the context window fills, Claude "may start 'forgetting' earlier instructions or making more mistakes," and recommends/clearbetween unrelated tasks. That is the same shape as the study's per-function odds decay, arrived at independently. - Restating a rule in the prompt works.
sub-agents.mdanddebug-your-config.mdboth prescribe exactly this for Explore and Plan subagents, which skip CLAUDE.md entirely: "restate the instruction in your delegating prompt."
Nobody documents the edit-versus-create gap. That one is the study's alone, and it is the most interesting claim in it — a convention that reads as obvious when you are producing a new file apparently competes with the surrounding style of the file you are modifying.
What to do differently on Monday
Stop treating CLAUDE.md as the lever and treat the prompt as the lever:
- When the task is editing existing code, name the convention in the prompt. Not "follow CLAUDE.md" — the actual rule, in the actual sentence.
- When you are deep into a long session, restate it again, or
/clearand reopen with the rule in the first message. - When you delegate to Explore or Plan, restate it, because those agents never load the file at all. That part is documented, not inferred.
- Keep maintaining the file anyway. The one enormous effect in the whole study is presence versus absence.
What is unverified here, plainly
The provenance is stated at the top rather than here, because a reader who meets a table of decimal percentages fifty lines before its disclaimer has already believed it. Take the figures as a hypothesis worth testing on your own repo rather than as a result.
What would settle it is a small headless harness. Put one mechanically checkable rule in CLAUDE.md, run the same task headless N times in each condition, and count violations with a grep rather than by reading transcripts:
#!/usr/bin/env bash
# Sketch only — not run. Adapt the rule and the checker to your repo.
set -euo pipefail
RULE_CHECK='grep -c "@invariant" src/generated.ts'
for cond in create edit; do
for i in $(seq 1 25); do
git checkout -- . && git clean -fd src/generated.ts || true
if [ "$cond" = "edit" ]; then cp fixtures/existing.ts src/generated.ts; fi
claude -p "Add a function that validates a user record to src/generated.ts" \
--output-format json > "runs/${cond}-${i}.json"
printf '%s %s %s\n' "$cond" "$i" "$(eval "$RULE_CHECK" || echo 0)"
done
doneTwo conditions, one rule, a countable outcome. Twenty-five runs per arm will not reproduce a 1,650-session study, but a 26-point gap is large enough that it should be visible at that sample size — and if it is not visible in your repo, that is the answer you actually needed.
Checkpoint
-
Which two variables in the study moved adherence, and which four did not?
Show answerAnswer
As reported, the two that moved were task type — writing new code at 71.3% against editing existing code at 45.1%, a 26-point gap — and session length, roughly 5.6% lower odds per additional function already written. The four with no significant effect were file length (25/100/250/500 lines), rule position (top/middle/bottom), one root file versus nested per-directory files, and injected self-contradiction. A seventh row carries the largest effect of all and is not a formatting knob: whether the file exists at all, 0% to about 68%.
Hold every one of those numbers loosely. They come from a blog post summarizing a preprint the tip's author did not read directly and whose identifier could not be confirmed, and nobody here reproduced any of it.
-
Which official docs page do you have to contradict to claim CLAUDE.md length has no effect on adherence — and what reason for keeping files short survives that contradiction anyway?
Show answerAnswer
memory.mdis the page you are up against: it sets the "target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence," and adds that "Shorter files produce better adherence."claude-directory.mdrepeats the 200-line target in its inline tips anddebug-your-config.mdblames files "grown long enough that individual rules get less attention." What survives either way is token economics — every line loads into every session and every subagent that loads it, shrinking the working context you have left, and the study never measured that. So even on the study's own terms length is not free. And since its result is reported rather than reproduced, the honest reading is that the received wisdom is unproven, not that the docs are wrong. -
You are 90 minutes into a session, editing an existing module. What do you put in your next prompt, and why is that different from what you would do when creating a new file?
Show answerAnswer
Put the convention itself in the prompt — the actual rule in the actual sentence, not "follow CLAUDE.md" — or
/clearand reopen with the rule in your first message. Both of the reported effects stack against you in exactly that scenario: editing scored 45.1% against 71.3% for new code, and the odds reportedly decay about 5.6% per function already produced, so deep into a session on an existing file is the worst case for both. Creating a new file is the condition where the file alone did best, so restating matters less there. Note which half rests on what: the decay has independent support inbest-practices.md, which says Claude "may start 'forgetting' earlier instructions" as the window fills and recommends/clearbetween unrelated tasks, while the edit-versus-create gap is the study's alone and undocumented. Restating costs a line either way, which is why it stays the safe move even if the figures do not hold.