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 (3)
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.