{"slug": "claude-code-auto-compact-what-survives-the-summary", "title": "Claude Code auto compact: what survives the summary", "summary": "Claude Code's auto-compact feature, enabled by default via the `autoCompactEnabled` setting, summarizes conversation history when a session nears the model's context window rather than ending it, while re-injecting from disk the system prompt, project-root CLAUDE.md, unscoped rules, auto memory, plan-mode plans, up to five recently modified read or edited files, and invoked skill bodies capped at 5,000 tokens per skill and 25,000 total. Besydr reported measuring nine compactions across a pytest benchmark run in two sessions of 18 and 16 requests, counting how often a rule stated ten or more requests earlier was broken. Users can steer the summary with `/compact` plus instructions, `/rewind`'s Summarize from here or Summarize up to here, `/autocompact` with a token count such as 500k, and `DISABLE_AUTO_COMPACT` to turn the pass off for one session.", "body_md": "# Claude Code auto compact: what survives the summary\n\nClaude Code auto compact folds old messages into a summary when the conversation approaches the model's context window, so a full window does not end your session. It is on by default. What happens when the Claude Code context window is full is therefore not an error but a rewrite: the conversation becomes a summary, while files the client trusts are re-read from disk. This post covers when the pass runs, what survives it, how to direct it, and what we measured across nine compactions in one benchmark.\n\n## When auto compact runs\n\nThe setting is `autoCompactEnabled`, default `true`, shown as **Auto-compact** in `/config`. The [context window documentation](https://code.claude.com/docs/en/context-window) describes the trigger: Claude Code compacts automatically as you approach the limit. Three controls change the moment:\n\n- `/context` shows current context usage, including the warning when the conversation has grown past the window:`Context exceeds the 200k-token limit by 94k tokens — run /compact or /clear to continue.` With auto-compact on, you can just send your next message.\n- `/autocompact` with a token count, such as`/autocompact 500k` , sets how full the window gets before the automatic pass runs — the auto compact threshold, in other words.\n- `DISABLE_AUTO_COMPACT` turns the pass off for one session. With it off, messages past the limit fail with`Context limit reached` until you run`/compact` or`/clear` yourself.\n\nOn 1M-context models a separate compaction window can sit below the model's window — the 200K boundary — so the warning can name a compaction window rather than the model's full context window size. A conversation left idle can also compact on its own; the [settings reference](https://code.claude.com/docs/en/settings-reference#idlecompaction) has the idle threshold.\n\n## What survives the summary\n\nCompaction summarizes the conversation history. It does not delete the mechanisms that load from disk. The [documentation](https://code.claude.com/docs/en/context-window#what-survives-compaction) lists what happens to each:\n\n| Mechanism | After compaction | \n|---|---|\n| System prompt and output style | Still apply | \n| Project-root CLAUDE.md and unscoped rules | Re-injected from disk | \n| Auto memory | Re-injected from disk | \n| The plan written in plan mode | Re-injected from disk | \n| Files Claude read or edited | Up to five re-read, most recently modified first | \n| Invoked skill bodies | Re-injected, capped at 5,000 tokens per skill and 25,000 total | \n| Nested CLAUDE.md and path-scoped rules | Reloaded on demand | \n| Conversation history | Summarized | \n\nThe practical reading: anything you wrote in a file comes back verbatim, and anything that only exists in the conversation comes back as the summary's version of it. A rule you stated in chat ten requests ago is in the summary's hands. A rule in CLAUDE.md is not.\n\n## Directing the summary\n\nThree commands give you a say in what the summary keeps, the core of Claude Code context management:\n\n- `/compact` with instructions:`/compact focus on the auth bug fix` . The summary keeps what you choose instead of what the automatic pass guesses is important. Run it before starting a long new task, not after the window is full.\n- `/rewind` , then**Summarize from here** or**Summarize up to here** : compact part of the conversation and keep the rest intact.\n- `/clear` starts a new session with an empty conversation. The earlier session is preserved and can be resumed, so clearing context is not deleting it.\n\n## What we measured\n\nBesydr (say: besider) is a program that supervises a coding agent and learns from its sessions. In [our Claude Code benchmark](https://besydr.com/blog/claude-code-benchmark-with-and-without-besydr), the long-sessions scenario worked on pytest in two sessions of 18 and 16 requests, and the conversation was compacted into a summary nine times. We counted how often a rule stated ten or more requests earlier was broken:\n\n| Setup | Rules broken | \n|---|---|\n| Claude Code alone | 0 of 96 chances | \n| Claude Code with Besydr | 0 in the same scenario | \n\nThis is a null result, and it is the point. Inside one session, Claude Code keeps the rules of that session through each compaction by itself; repeating them with every prompt, as Besydr does, added nothing here. The decay we measured lives elsewhere: across sessions and projects, where rules from an earlier session were broken 47 times per 100 requests without Besydr and 4 with it. If your agent forgets a rule, check first whether the rule ever left the conversation it was stated in.\n\n## What a summary can still lose\n\nThe null result covers stated rules, not everything. A compaction folds much of what it touches into prose, and most of that is tool results: the output of commands and file reads the agent ran earlier. A summary that drops an error message or a path the remaining work depends on costs a re-run later.\n\nSince version 0.4.0, Besydr guides this step on Claude Code (the main session only, not subagents) and OpenCode: before the client compacts, Besydr's decision model — the model Besydr calls for its own judgments — marks which earlier tool results the current task still needs, and the client gets instructions to keep their details — names, paths, error text, numbers — and drop the rest. It costs one extra decision-model call per compaction and fails open: if the model is slow or unreachable, the client compacts as it would have. The [release post](https://besydr.com/blog/besydr-0-4-0) has the settings and limits. The local program is free with octomind and needs a [licence](https://besydr.com/pricing) with Claude Code after a trial.\n\n## Sources and method\n\n- Trigger, controls and the survival table: the [context window](https://code.claude.com/docs/en/context-window) ,[settings reference](https://code.claude.com/docs/en/settings-reference) ,[error reference](https://code.claude.com/docs/en/errors) and[interactive mode](https://code.claude.com/docs/en/interactive-mode) pages, read 2026-11-29.\n- The measured numbers come from [our benchmark](https://besydr.com/blog/claude-code-benchmark-with-and-without-besydr) : the long-sessions scenario, three runs per setup; 96 chances without Besydr.\n- This post was drafted with AI assistance from these sources.", "url": "https://wpnews.pro/news/claude-code-auto-compact-what-survives-the-summary", "canonical_source": "https://besydr.com/blog/claude-code-auto-compact", "published_at": "2026-12-02 17:43:17.274476+00:00", "updated_at": "2026-12-02 17:43:19.842600+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "large-language-models", "developer-tools"], "entities": ["Claude Code", "Anthropic", "Besydr", "pytest"], "also_reported_by": [], "takeaway": "Anything written to a file (CLAUDE.md, auto memory, plan-mode plans) is re-injected verbatim after auto-compact, while rules stated only in chat survive only as the summary's version, so put durable instructions in CLAUDE.md and run `/compact` with explicit instructions before a long new task.", "recommendation": {"advice": "Move rules you need kept into project-root CLAUDE.md rather than stating them in chat, and run `/compact focus on <task>` before starting a long new task instead of waiting for the window to fill.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/claude-code-auto-compact-what-survives-the-summary", "markdown": "https://wpnews.pro/news/claude-code-auto-compact-what-survives-the-summary.md", "text": "https://wpnews.pro/news/claude-code-auto-compact-what-survives-the-summary.txt", "jsonld": "https://wpnews.pro/news/claude-code-auto-compact-what-survives-the-summary.jsonld"}}