TL;DR: I got paranoid that long coding sessions were compacting away the rules pinned in CLAUDE.md, so I ran an experiment to measure it. I planted a unique canary ID in CLAUDE.md, made agents grind through long build loops, then checked if they could still recall the ID at the end. Across three runs retention held around 88–97%. It only really dipped (~80%) when the rule was at the very bottom of the file and the task was long. What I was actually testing When a Claude Code session runs long, it auto-compacts: it summarizes older context to free up room. My worry was that the rules you pin in CLAUDE.md (your “always do X, never do Y” stuff) might get summarized away without you noticing. So I gave the model a secret ID to remember, buried it in CLAUDE.md, made it work for a long time, then asked it to recite the ID back. If it couldn’t, the rule “decayed.” The setup Each test run is one headless Claude Code session. It gets a CLAUDE.md containing a planted ID like INV-<uuid> , and is told to do exactly N rounds of: read every file in the repo, add a ~150-line module + a test, run the suite, append a changelog line. Those repeated full-repo reads are what bloat the context and (supposedly) trigger compaction. At the very end, it has to recover the ID from its own memory and print it. I varied three things: How long the task ran: 8, 16, or 32 build rounds Where the ID lived in CLAUDE.md: top header, buried in the middle, or a footnote at the bottom Results Longer tasks decayed a bit more: 8 rounds → 97.0% retention 16 rounds → 94.5% 32 rounds → 91.3% Where the rule sat in the file mattered more: buried in the middle → 97.8% top header → 95.8% footnote at the bottom → 88.3% The two effects stack. The single worst combination was a rule sitting at the bottom of the file in a 32-round task: only 80.6% survived. The exact same bottom-of-file rule in a short 8-round task survived 97.4%. So it’s the bottom-of-file- and -long-task corner that’s dangerous. Effort level made basically no difference. submitted by /u/Limp-Park7849
Originally posted by u/Limp-Park7849 on r/ClaudeCode
