What happens at compaction
Compaction replaces the older conversation with a summary. Claude Code starts it when the context window, the amount of text the model can use when it answers, fills up.
The hooks documentation (hooks are scripts run on agent events) says important details can be lost at compaction. A SessionStart hook with the compact source can hand the agent text afterwards.
Compaction is also still being tuned: each of the five Claude Code releases 2.1.326 to 2.1.330 (16 to 20 November 2026) changes something around it, for example a fix for automatic compaction reusing an earlier system prompt (2.1.328, 19 November 2026).
What I ask the agent to reread
My collaboration rules sit in a separate file that my project instructions only link to. One of the rules allows a chat reply of at most ten lines. The agent reads it at the start like any other file, so compaction probably summarizes it with the conversation (I haven’t tested that). My hook therefore tells the agent to read it again.
Originally the hook printed the full rules. In my run on 11 November 2026 its output was about 14.5 kB, and the agent got a file path and a preview of the first 2,000 characters instead of the text. The hooks documentation says output over 10,000 characters is replaced this way.
Until 22 November 2026 the hook asked the agent to read four files. That day I considered whether rereading everything after each compaction makes sense. The summary already carries the conversation, the handover note and the activity log are about other conversations, and the agent reads the memory-writing rules only before it writes to memory. So only the collaboration rules stayed.
What I tested on 13 October 2026
I took 30 of my real messages from the previous weeks to see how the rules affect reply length. Claude Code (model Opus) answered each one on its own, in a read-only copy of my repository, in two variants: with the rules in context and without them. Twenty messages were for tuning, ten for a check. My rule allows at most 10 lines; I counted the replies that exceeded it.
With just one line about reply length instead of the whole file, none of the 10 check replies went over the limit. For the 20 tuning messages, another model compared pairs of replies without knowing which had the rules. It preferred the reply with the rules 11 times and the one without 4 times, rated 5 pairs equal, and flagged nothing important as missing.
What this does not show
The 13 October 2026 test is one run on 30 messages, so one message is 5 percentage points in the tuning set and 10 in the check set. I measured only reply length, not quality, and another model judged quality. I didn’t simulate compaction. I ran the test with and without the rules in context. My real transcripts give a different comparison, by the moment of compaction rather than by the rules: according to my note of 13 October 2026, over 30 days 14 % of replies went over the 10-line limit before compaction and 19 % after it. The note gives no reply counts, and I can’t tell whether the rules were in context for each reply. I haven’t re-measured reply length since switching from four files to one.
Sources
- Anthropic, Automate workflows with hooks (Claude Code docs, opened 22 Nov 2026): important details can be lost at compaction; a SessionStart hook with the compact source can hand the agent text afterwards.
- Anthropic, Claude Code changelog, versions 2.1.326 to 2.1.330 (16 to 20 Nov 2026): changes around compaction in five consecutive releases, including the fix in version 2.1.328.
- Anthropic, Hooks reference (Claude Code docs, opened 22 Nov 2026): hook output over 10,000 characters is replaced by a file path and a preview of the first 2,000 characters.