Published on , Aurélien Vandaële

What does Claude Code keep after auto compact? What I write to disk so nothing gets lost

When the conversation nears the limit, Claude Code replaces it with a summary and reloads CLAUDE.md, auto memory, the plan-mode plan and recent files from disk. Anything that only exists in the thread, a decision, an approved text, an instruction given in passing, can disappear. My rule: whatever must survive is written to a file at the moment it is decided, and long work resumes from a ledger on disk, not from the session's memory.

The problem: a summary does not keep everything

Compaction is what lets a long session keep going. Claude Code starts it on its own as the context limit approaches, and you can start it yourself with /compact. The documentation is clear about the result: the summary keeps your requests and the key code snippets, but detailed instructions given early in the conversation may be lost.

The trap is that nothing tells you what went missing. The session carries on, the agent answers with confidence, and it now works from a summary it did not choose.

What survives, and what does not

The documentation page on the context window lists what happens after a compaction:

  • Reloaded from disk: the project-root CLAUDE.md, rules without a paths: field, auto memory, the plan written in plan mode.
  • Reloaded on demand: CLAUDE.md files in subfolders and path-scoped rules, only when Claude touches a matching file again.
  • Partly reread: up to five files read or edited during the session, most recently modified first. A file over 5,000 tokens comes back as a path only.
  • Truncated: the body of invoked skills, capped at 5,000 tokens each and 25,000 in total, oldest dropped first.
  • Summarised with the rest: everything said in the conversation, including context that hooks added earlier.

In other words, the disk is the only reliable memory. What lives in a file comes back; what only lives in the thread goes through a summary.

My method: write it down when it is decided

  • Approved text goes into a file right away. Not at the end of the session, not "once the batch is done". The rule is written as such in the skill involved.
  • Long work keeps a ledger on disk. For each plan, my agent chain writes a progress.md file: the plan, the starting commit, then one line per finished task. The orchestrator's instructions say: after a compaction, trust the ledger and git log, not your memory.
  • Agents read files; nothing is pasted to them. Each task has its brief written to disk. Nothing large is pasted into a prompt, so nothing depends on what a summary kept.
  • One task, one fresh session. A session that does not mix topics reaches the limit less often. I cover this rule in the article on token usage.

In my global settings I changed nothing: no custom threshold, no compaction hook. Everything rests on what is written down.

A real example: the ledger that lets the chain resume

At the end of October, my chain ran the plan for the new onboarding of ResellStats, one of my apps. That plan's ledger is 82 lines long. It looks like this, in reduced form:

plan: docs/plans/<plan>.md
BASE=<starting commit>
task1 complete <sha> rounds=2
RULING task4: <decision taken along the way>
DEFERRED task3: <item left for later>

It holds 13 complete lines, 13 RULING decisions taken along the way and 7 DEFERRED items. That same evening the chain stopped twice, at task 8 and then at task 9. On each restart, the orchestrator rereads this file and resumes at the first task without a complete line. Nobody had to remember what was done, and the ledger stayed a single file from start to finish.

The RULING lines are the most valuable. A decision such as "this step is removed in task 4 instead of task 8" is made in the conversation. If it only lived there, a compaction could shrink it to half a sentence, and the next agent would do the opposite.

What went wrong

  • Approved text lost. In early October I was preparing a batch of TikTok carousels with Claude. The texts had been reviewed and approved in the conversation, but not yet written to the batch file. The conversation was compacted, and those approved texts were lost. Since then, the skill states plainly that the batch file is written as soon as a text is approved.
  • An instruction given in passing. The auto mode documentation says so: a boundary stated in the conversation, such as "don't push", can be lost to a compaction. For a lasting boundary it recommends a deny rule. I don't have one yet, as I note in the article on auto mode.
  • A skill that is too long. After a compaction, only the start of a skill comes back. A rule placed at the bottom of a long file can therefore drop out. That is why my skills open with what must never be forgotten.

How to get started

  • Type /context to see what fills the window, before compaction decides for you.
  • Before a long task, run /compact yourself with an instruction, for example /compact focus on the auth bug fix. The summary keeps what you chose. You can also add a "Compact Instructions" section to your CLAUDE.md.
  • Switch topics with /clear rather than /compact: the documentation states that /clear costs nothing, while /compact rereads the whole conversation.
  • For any multi-step work, have Claude write a tracking file, one line per finished step and one line per decision, and tell it to resume from that file.

The threshold is set with /autocompact, for example /autocompact 500k, and DISABLE_AUTO_COMPACT=1 turns automatic compaction off. I don't use either: moving the moment of the summary does not change what it forgets.

Article written with the help of AI, from my daily practice and my projects.

The whole notebook