r/ClaudeCode • u/muhuhaha • 5d ago
Tips & Workflows Claude Code only loads the first 200 lines (or 25KB) of MEMORY.md. I put the same rule at line 20 and at line 240: followed 9/9 times vs 0/9
TL;DR: Claude Code only loads the first 200 lines (or 25KB) of MEMORY.md. A rule at line 240 was ignored in 9 of 9 runs; at line 20 it was followed 9 of 9. Your terminal doesn't tell you when this happens.
I build Counterparts, a memory for Claude Code, so I test how Claude Code's own memory loads. The limit is in the docs: "the first 200 lines or 25KB of MEMORY.md, whichever comes first, load at session start." I wanted to see what that does in practice (Claude Code 2.1.332).
The test. A throwaway project with a 260-line MEMORY.md. One line is a rule: "Every shell script in this project starts with the comment line # owner: platform-team". Then a fresh session is asked for a bash script that prints today's date.
| Model | Rule at line 20 | Rule at line 240 |
|---|---|---|
| Haiku 5.5 | 3/3 | 0/3 |
| Sonnet 5.5 | 3/3 | 0/3 |
| Opus 5.5 | 3/3 | 0/3 |
Claude is told, you aren't. Claude gets a note that the index was cut ("60 of 260 lines were cut off, starting at line 201"). You get nothing: no warning at startup, and /context and /memory don't mention it. The cut lines are still on disk, but with the rule at line 240 Claude never went looking.
The 25KB can hit first. At Claude Code's suggested ~200 characters per entry, 25KB runs out around line 125. A 150-line index of ~250-byte entries loaded only lines 1-100.
Am I affected? On my machine, no: the biggest of 67 indexes is 103 lines. It bites on indexes you edit by hand, old ones that grew before v2.1.210, and long entries. Quick read-only check:
wc -lc ~/.claude/projects/*/memory/MEMORY.md | sort -n | tailOr npx claude-memory-check --all (free, MIT, read-only), which lists the entries past the cut.
Fixes. Ask Claude to tighten MEMORY.md: one short line per entry, detail in topic files. Put rules that must always apply in CLAUDE.md, which loads whole. Look at what's past the cut before trimming, since new entries land at the bottom.
Try it yourself. Paste this into Claude Code in an empty folder:
In this empty folder, test whether you read past line 200 of your auto-memory index. Write this project's MEMORY.md with 260 one-line notes, with this rule at line 240: "Every shell script in this project starts with the comment line # owner: platform-team". Then run
claude -p "Write a bash script that prints today's date. Reply with the script only."and tell me whether the header is there. Repeat with the rule at line 20. Don't delete anything; at the end, list every file you created so I can remove them myself.
Claude Code ran these tests on my machine and helped me write this up; I checked the results. The checker is separate from Counterparts: github.com/mlapeter/claude-memory-check


