A rule meant for the whole session does not belong in the chat. When a coding agent forgets context halfway through a long session, look at compaction first. Once the context window is nearly full, Claude Code replaces the conversation with a summary that the model writes, and a rule you gave only in the chat survives only as far as that summary kept it. Move every rule that has to last into the CLAUDE.md at the project root, and keep Claude Code up to date.
Claude Code's memory documentation has a troubleshooting entry called "Instructions seem lost after /compact". It says "Project-root CLAUDE.md survives compaction". After /compact, Claude reads that file from disk again and puts it back into the session. Nested CLAUDE.md files and rules scoped to paths load again only when Claude next works with files they apply to.
My own working rules for coding agents live in CLAUDE.md files in my repositories, each with the date it was added and the reason. Version 2.1.311, released on 26 October, fixed Claude seeing "stale MEMORY.md and CLAUDE.md content right after automatic compaction when those files were edited earlier in the session". Before it, a CLAUDE.md you had edited during a session could reappear in its old form after the next automatic compaction.
Two later fixes are about the same moment. A "Prompt is too long" error after automatic compaction, in sessions where a very large CLAUDE.md had changed since it was last sent, was fixed in 2.1.317 on 3 November. And 2.1.328 stopped automatic compaction from "reusing the session's earlier system prompt instead of rebuilding it the way /compact does".
On 19 November 2026, the day 2.1.328 came out, I counted the changelog lines that contain the word compact in that release and the 19 before it, back to 2.1.305 on 20 October. There are 55, and in 17 of the 20 releases at least one of them begins with "Fixed". Counting by one word is crude, and two of the 55 use it in another sense, "a compact list" and "compact JSON". I left them in.
Run claude --version before a long session. On anything older than 2.1.328, at least one of these three fixes is missing.
Everything above is as of 19 November 2026, when I read the changelog, the release dates on GitHub and the memory documentation. Releases after 2.1.328 are not in the count.
I work on Mnemoverse; the quotes here are Anthropic's, and the count is mine.

Top comments (9)
The count measures how often compaction was worked on, which is not the same as how much forgetting went down. A changelog line is evidence someone tried; it is not evidence the symptom changed.
The direct measurement is available and cheap, and it would make the version advice much stronger: log the message list and the token count at each turn, then compute per session how many times compaction fired and what fraction of pre-compaction content survived into the next turn. That gives a survival rate you can chart against the version axis. "2.1.328 dropped survival loss from X to Y" is a much harder claim than "seventeen of twenty releases touched it", and it is the one a reader can act on.
The version check is still the right first move. It is just measuring the effort rather than the effect.
You are right that a changelog line shows a fix shipped, not that the agent forgets less. The count in the note only shows how often this part of Claude Code changes, and the advice does not lean on it. It rests on the three fixes: on a version older than each of them, that one failure can still happen. Whether forgetting as a whole went down is the question your test would answer.
For that I would not compare the text before and after. The summary is a rewrite, so token overlap misses what it kept in other words, and it says nothing about what the agent still obeys. Closer to forgetting is a script that gives a handful of rules in the chat, forces compaction, and checks whether the next turns still follow them, run the same way on 2.1.305 and on 2.1.328. I did not run that for this note.
You are right about the token overlap, and I would drop that suggestion - the summary is a rewrite, so overlap measures shared wording rather than retained content. The 2.1.305 against 2.1.328 version of your script is the right shape.
One thing I would add, because it decides whether the result is honest: plant two things rather than one. A rule stated explicitly ("always answer in the user's language") and an incidental fact mentioned once in passing ("the staging database is read-only"). Both are context, and the failure people actually complain about is almost always the second - the agent keeps the instructions and loses the passing detail.
A test that only checks planted rules will report clean while the thing users actually lose is still missing. The two-track version tells you whether compaction drops salience or drops content.
Agreed, and the split also says where each of the two can live. If the rule sits in the project-root CLAUDE.md, the test only checks the reload from disk, since Claude Code reads that file again after compaction. A passing remark like the read-only staging database is not the kind of thing anyone writes into CLAUDE.md, so it survives only as far as the summary kept it, and that is where 2.1.305 and 2.1.328 could actually differ.
You are right and it breaks my version of the test: if the rule lives in CLAUDE.md it gets reloaded from disk after compaction, so the rule half measures the reload path and not compaction at all. The comparison I proposed would only have separated 2.1.305 from 2.1.328 if the bug reached the file-reload path, which is not where I said it was.
The corrected version is to keep CLAUDE.md out of it entirely. Both items in the chat only: one explicit rule, one passing fact, both existing solely in the transcript. Then both are subject to the same mechanism and whatever difference you see is compaction and nothing else.
Which is also an argument for testing the CLAUDE.md case separately rather than folding it in. Two mechanisms, two tests - and the file-reload one probably shows nothing, which is the useful result, because it tells people which mitigation is actually load-bearing.
One case where the file-reload test should show something: edit CLAUDE.md during the session, before compaction fires. Before 2.1.311 Claude could see the old content of a CLAUDE.md edited earlier in the session right after automatic compaction; that is the first fix the note quotes. So on 2.1.305 the reload path has a known failure and on 2.1.328 it should not, as long as the test changes the file mid-session instead of leaving it as it was at the start.
You are right and I withdraw the claim - I said the reload path would probably show nothing, and the stale-CLAUDE.md-after-compaction bug is exactly a reload-path failure with a version boundary. It makes the two tests asymmetric in a useful way: that one has a known bug and a known fix, so it can validate the version axis; the chat-only one is still exploratory.
One thing the test has to record, given your design: when the edit happened relative to compaction. If the file is edited before compaction fires, the failure is reachable. If it is edited after, a clean result is guaranteed and means nothing. So the run should log the edit timestamp and the compaction timestamp and only count runs where the edit preceded compaction - otherwise the passing case and the untested case are indistinguishable.
Which is the same distinction we started with, applied to the harness itself.
The harness can log both times itself instead of inferring them. PreCompact, PostCompact and InstructionsLoaded are all older than 2.1.305 in the changelog, so both versions have them. The current docs give the two compaction hooks a trigger field, manual or auto, so a PostCompact hook can write the compaction time and trigger to a file, and InstructionsLoaded records each load of CLAUDE.md into context. The edit time is the file's modification time. A run counts only if the edit time is earlier than the compaction time. The 2.1.311 fix names automatic compaction, so I would also drop runs where the trigger was manual.
The hook design closes it, and the manual-trigger filter is the part I missed - the fix names automatic compaction, so keeping manual runs in would only add runs where the path is not exercised.
The last field I would add to InstructionsLoaded is a hash of what was loaded, not just that it loaded. The bug you are hunting is stale content loading successfully, so "InstructionsLoaded fired" is true in both the buggy and the fixed case. With a hash per load the test asserts something sharper than a version number: the content the agent saw after compaction equals the content on disk at that moment. That is the assertion that can fail on 2.1.305 and pass on 2.1.328 for the reason you described, rather than by coincidence.
Which is the same distinction once more - log the thing that can be wrong, not the thing that happens either way.