Notes on coding agents and the pages they leave behind, on moving between notes apps, and on the plain mechanics of keeping what you think. Written and published from a Sumibako vault.
Claude Code compaction: what it keeps, what it loses, and the file that survives it
What Claude Code's compaction keeps and drops, when it fires without asking, the idleCompaction setting that stops it, and the one habit that makes it harmless.
Prashant Shaw
Founder, Sumibako
8 min read
On 1 October somebody opened an issue against Claude Code that I have read more times than is healthy. They keep about twenty sessions open at once on long projects. They updated to version 2.1.286, went to bed, and in the morning seven of those sessions had been quietly compacted while they slept. Nothing was near the context limit. "When I came back, each had a summary in place of its working context: my exact instructions, the reasoning behind decisions, and the methods we'd agreed on were gone from what the session actually sees."
Compaction is the thing Claude Code does when a conversation gets too long: it replaces the history with a summary so the session can carry on. Most of the time you only notice a line in the terminal and a slightly forgetful assistant. Occasionally you notice it the way that person did. This post is what compaction keeps, what it loses, when it fires without asking, and the one habit that makes all of that stop mattering. Everything below was checked on 29 October 2026 against Anthropic's own documentation and that issue, which Anthropic answered.
🗜️ What compaction actually does
Anthropic's description is short and honest. When context fills up, Claude Code "compacts the conversation into a summary. The summary keeps your requests and key code snippets, but detailed instructions from early in the conversation may be lost." The sentence after it is the whole lesson of this post, and it is in the official docs: "Put persistent rules in CLAUDE.md rather than relying on conversation history."
The summary is written by a separate request. It "repeats your conversation's system prompt, tools, and the history being summarized" and ends with an instruction to summarise, which is why a /compact on a long session is itself a large request. Anthropic's
has the detail: while the cache is warm, a mid-session compaction "costs a fraction of what the context size suggests", and after a break longer than the cache lifetime "the summarization request reprocesses that history as uncached input." Compaction is cheapest in the middle of work and dearest when you come back to an old session, which is exactly backwards from when you would like to do it.
📋 What survives, in Anthropic's own table
The documentation has a table called What survives compaction, and it is worth reading as a list of what Claude Code can rebuild from disk versus what only existed in the conversation.
What it was
After compaction
CLAUDE.md at the project root, and unscoped rules
Re-injected from disk
Auto memory
Re-injected from disk
The plan Claude wrote in plan mode
Re-injected from disk
Files Claude read or edited
Up to five re-read, most recently modified first; a file over 5,000 tokens comes back as a path, not its content
Skill descriptions
Rebuilt and re-injected (v2.1.304 or later)
Skill bodies you invoked
Re-injected, capped at 5,000 tokens each and 25,000 in all, oldest dropped first
Nested CLAUDE.md files and path-scoped rules
Reloaded on demand, when Claude next touches a matching file
Background commands and subagents
Keep running; Claude is reminded they exist
Context that hooks added earlier
"Summarized with the rest of the conversation"
Everything you said, and everything Claude decided
The summary, and whatever the summary kept
Read the right-hand column and a pattern appears. Everything that survives intact is a file. Everything that is lossy is conversation. A rule you typed in chat three hours ago is conversation. The reason you rejected the first approach is conversation. The instruction not to touch the migrations folder is conversation, and the docs say as much in a different place: a boundary you state in the conversation "can get lost when the conversation compacts, so anything that matters belongs in a deny rule."
📝NOTE
Tasks are the exception that proves it. Claude Code's own task list "persist across context compactions", because it is kept outside the conversation. Everything that survives is kept somewhere other than the chat.
⏰ The three ways it fires
There is a manual one and two automatic ones, and the second automatic one is the one from the issue.
1️⃣ You run /compact. With or without instructions. /compact focus on the auth bug fix tells the summariser what to keep, and the docs recommend doing it "at a natural break in your work, such as between tasks, instead of waiting for auto-compaction to trigger mid-task." You can also compact part of a conversation: /rewind opens a menu with Summarize from here and Summarize up to here, which is the right tool when only the first hour has gone stale.
2️⃣ The window fills. By default Claude Code "compacts when the conversation reaches the model's context limit", and on the models with a native million-token window, which is the Fable models, Sonnet 5 and later, Haiku 5.5 and Opus 4.7 and later, that happens "at about 967K tokens by default." You can bring it forward with /autocompact 500k, or turn it off with "autoCompactEnabled": false, after which the session stops with a context error instead of summarising.
3️⃣ You walk away. This is the one that bit the issue's author, who first saw it in version 2.1.286. The changelog describes it like this: "a 200K+ token conversation left idle for about 54 minutes is compacted before its one-hour prompt cache expires, so your next message doesn't reprocess it all". The logic is cost: on a subscription the cache lasts about an hour, and a cold cache means the whole conversation is re-read at full price. The best practices page puts it plainly: "after lunch you continue from a summary."
The issue's author understood the cost logic and disagreed with the trade: "the context is the valuable part, and a cache re-read is a cost I'd gladly pay to keep it." Anthropic's answer came within a day, "Appreciate the feedback, setting is coming", and five days later: "Version 2.1.290 now has a idleCompaction setting to allow opting out, and the trigger is now 'auto'." So today you can turn it off:
That goes in any settings.json, there is an Idle compaction row in /config since 2.1.302, and CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS raises the 200K floor if you would rather keep the behaviour for truly enormous sessions. Note the order of the switches: turning auto-compact off turns idle compaction off with it, but you can keep the first and lose the second, which is the combination most people in that thread wanted.
🪝 Hooks can see it coming, and cannot save it
Claude Code fires a PreCompact hook before every compaction and a PostCompact hook after, each with a matcher of manual or auto, and a SessionStart hook with source set to compact once the new context is built. A PreCompact hook that exits with code 2 blocks the compaction outright, which is a blunt instrument but a real one. The input tells you the transcript path, and PostCompact hands you the summary itself as compact_summary.
Here is the smallest useful one, a log of when it happened and in which project, so that it was fine when I left is at least a question you can answer:
What a hook cannot do is rescue the conversation. Nothing you put in a hook makes a sentence from three hours ago survive verbatim; the summariser decides that, and you only get to nudge it with /compact instructions or a "Compact Instructions" section in CLAUDE.md. The transcript is still on disk as a .jsonl file, which is how the issue's author rebuilt their sessions by hand, and resuming a compacted session opens "at a Conversation compacted row". You can read what was lost. The session cannot.
📝 The habit: write it down before it is summarised
Everything above points the same way. Files survive, chat does not, so the things that matter should be in a file before the summariser gets to them. The question is which file, and there are three honest answers.
What it is
Where it goes
Why there
A rule for every session in this repo
CLAUDE.md, or a deny rule for the ones that cannot bend
Re-injected after every compaction and loaded at every start
A correction Claude keeps needing
Auto memory, which Claude writes itself
Re-injected, first 200 lines or 25KB
The state of this piece of work: what was decided, what was rejected and why, what is half done
A handoff page, outside the repo
It is for you and the next session, not a rule for all of them, and it has to be readable when the session is gone
The first two are Anthropic's own recommendation and need no help from me. The third is the one the table in the docs has no row for, and it is the one that was lost in that issue: not rules, but the grounding of a particular job. CLAUDE.md is the wrong place for it, because it would load into every session forever. The plan file is close, and it does survive compaction, but Claude Code deletes plans after 30 days and a plan is what you intended, not what happened.
So I keep a handoff page per piece of work, and I ask Claude to update it at the points where a compaction would hurt: after a decision, before I step away, and whenever I notice the context getting long in /context. The same template I use when a chat gets too long works here: what the job is, what has been decided and why, what was tried and rejected, what is in flight, and what to do next. When the session compacts, idle or otherwise, the next prompt is read the handoff page and carry on, and the summary's gaps stop mattering.
The page lives outside the repo on purpose. I make Sumibako, a notes app Claude Code can write a page into with one command and read back the next morning, from a new session, a different machine, or a browser on a phone when I am trying to remember what Tuesday's session decided. Any file works for the habit. A page you can open from anywhere, with a link you can hand to the next person, is just the version I kept using.
💡TIP
If you only change one thing: before you step away from a session that is past 200K tokens, run /compact with instructions or ask Claude to update the handoff page. Either one puts the choice of what to keep in your hands instead of the idle timer's.
GitHub: issue 98747, idle compaction silently discards working context, opened 1 October 2026 and answered by Anthropic
Cursor's pricing since SpaceX: the X Subscription tiers, what happened to the $20 Pro plan, what Claude costs in Cursor now, and when Claude Code is cheaper.