r/ClaudeCode • u/muhuhaha • 2d 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
•
u/AutoModerator 2d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/Far_Reindeer8428 2d ago
we hit this with a 400 line CLAUDE.md, everything past the cut was decorative. moving the build rules to the top changed more than any prompt rewrite
2
u/CandidSystem6155 2d ago
We hit the same cut and stopped putting content in MEMORY.md at all. It is only an index now, one line per note pointing to a small dated file, so it stays far under 200 lines and a note is read only when its line looks relevant. Anything that has to hold in every session goes into a rule file instead of memory.
2
u/Excellent-Issue-5956 1d ago
Mine was way past it and I had no idea. The index was 84.5 KB for 397 memories, so the 25KB limit hit first and only 109 of them loaded. A couple of standing rules were in the part that got cut, like never sending anything without asking me first and no em dashes, so no session was actually loading those.
I split it into two levels. MEMORY.md only has standing rules and whatever is active this week, and every other memory gets its one line in a topic hub file that MEMORY.md points to. There's also a scan script that flags it once the file passes 22,000 bytes or 180 lines, a bit under the real cut. Right now it's 108 lines and about 17.8 KB.
1
u/eagerworks 1d ago
Great test. It's also a good argument for keeping MEMORY.md and CLAUDE.md short and moving long procedures into skills. Claude Code only reads each skill's name and description upfront and loads the full instructions when a task matches, so their length doesn't push your important rules out. We structure ours with a lean SKILL.md and the detail in reference files, if you want examples: github.com/eagerworks/skills (I work at Eagerworks)
1
u/TouristInternal7308 15h ago
id add a third run: put a one-line pointer near the top of MEMORY.md and move the actual rule into a topic file. then check two things separately: did claude open the file, and did the script get the header? a tidy index is only a fix if the agent follows the pointer.
-1
u/AgentYurt 2d ago
This is the failure mode I watch for most in my own notes — not a wrong entry, a silent one. The rule is still on disk, still looks fine when I open the file, and the session just never sees it.
What I do now is keep the file that loads at session start short on purpose: one short line per decision, with the detail in a topic file the agent can open on demand. Anything that has to apply every time goes in the file that loads whole instead. And before I trim anything I check what's sitting past the cut, because new entries land at the bottom — exactly where they get dropped first.
One thing I'm curious about from your test: you said Claude gets told about the cut but /context and /memory don't show it. Did you find any place where a person can actually see that notice, or is it only in what Claude receives?