
Daily Digest
Make your rules survive compaction
We forced compaction on Claude and two small models. Here's what held.
The problem
Long coding sessions get compacted. The agent swaps the conversation for a summary, and summaries lose things. On Reddit, people describe agreeing on a rule with the agent, then watching it break that rule an hour later. We wanted to know if that holds up, and where a rule should live.
The technique
Put must-keep rules where compaction cannot touch them. The Claude Code docs describe two ways. A root CLAUDE.md is re-read from disk after compaction. A SessionStart hook with the matcher compact runs after compaction, and its output is added to the compacted context. Nested CLAUDE.md files and path-scoped rules come back only when Claude reads or edits a matching file again.
What we saw
We planted five rules in a working session: never edit a frozen folder, use one package manager, one date format, one database, never print secrets. We forced a real compaction, then tested each rule with a task that would break it. We ran five sessions per setup, so each setup tested twenty-five rules.
Claude Code 2.1.319, model claude-sonnet-5-5, medium effort. Rules only in chat: 25 of 25 held. Only in CLAUDE.md: 25 of 25. Chat plus the hook: 25 of 25. Low effort, bigger files, a focused compact, and three compactions in a row gave the same result.
The control was sessions with no rules anywhere. They held 3 of 25 after compaction, so the tests can catch a forgotten rule. Chat-only rules survived because Claude's summary quoted every one of them.
We also ran two small local models, Qwen 2.5 3B and 7B at 4-bit with greedy decoding, and had each one summarize its own history. With rules only in chat, 3B held 14 of 25 and 7B held 16 of 25. With rules in the system prompt, 3B held 17 of 24 and 7B 13 of 20. With rules re-added after the summary, 3B held 16 of 24 and 7B 17 of 25. Compaction wasn't their main problem: before compaction, chat-only rules held just 6 of 25 on 3B and 10 of 25 on 7B. The secrets rule never held, before or after, and the frozen folder failed more often than it held.
Limits
We compacted early, at about 30,000 to 64,000 tokens, well before the window was full. Our rules were short and explicit. Vaguer decisions and much longer sessions may lose more. We didn't test those. The small-model summarizer stands in for Claude's. On Claude we measured no gain from the file or the hook. Qwen 7B's system-prompt arm has four sessions, not five, because an out-of-memory crash lost one history and we didn't rerun it.
Try it
Move your three to five must-keep rules into the root CLAUDE.md as plain statements. Optionally add a compact-matcher SessionStart hook that prints the same lines. Run slash compact, then ask for something that would break each rule. If one breaks, make it shorter and more explicit.
Sources
Did it work for us?
Partly
Claude Sonnet 5.5 kept 25/25 rules in all three setups; Qwen 3B/7B held 14/25 and 16/25 in chat only.