What is auto-compact in Claude Code?
Auto-compaction is Claude Code summarising older conversation history when a session approaches the model's maximum input size, to free space for the work still ahead. Anthropic lists it beside prompt caching as one of two automatic cost optimisations. The important part for anyone who's seen the warning: it signals a context boundary, not a usage or billing limit.
- What triggers it
- Context limit conversation nears max input
- What it does
- Summarises older history, keeps recent
- Is it a usage cap?
- No docs say so explicitly
- Why it exists
- Cost + fit tokens scale with context
- Sibling feature
- Prompt caching the other auto-optimisation
- Side effect
- Detail loss summaries aren't transcripts
The doc corrects the usual misreading directly.
Anthropic's cost guidance describes it plainly: Claude Code "automatically optimizes costs through prompt caching, which reduces costs for repeated content like system prompts, and auto-compaction, which summarizes conversation history when approaching context limits".
And in the troubleshooting list, the misconception is named outright: a context or auto-compact warning is "not a usage limit" — the conversation has simply grown close to the model's maximum input size, and Claude Code summarises older history to free space. Anyone arriving here after seeing that banner mid-task is usually worried about the wrong thing.
The reason both features exist is the same arithmetic: token cost scales with context size, so the more history the model carries, the more each turn costs. Compaction trades fidelity for room.
What it means for your session.
A summary is lossy by definition. After compaction the model still knows the shape of what happened — decisions taken, files touched — but not every line of the transcript that led there. That's the practical cost, and it's why a very long session sometimes repeats a question you answered an hour ago.
The defence isn't fighting the feature; it's keeping durable facts somewhere durable. Project instructions in CLAUDE.md survive compaction because they're re-read, not remembered.
Compaction reduces the context being carried, which reduces per-turn cost. But arriving at compaction at all means you've been paying to carry a large context for a while. Starting a fresh session for a new task is cheaper than compacting an old one, and gives better answers.
If you want to see what your context is actually costing, the usage panel flags long context when it accounts for 10% or more of recent usage.
They pull in different directions and it's worth not confusing them. Prompt caching makes repeated context cheaper to send — the content stays, the price drops. Compaction makes the context smaller — the price drops because the content goes.
Caching is free money; compaction is a trade. Both happen automatically, which is why sessions can get cheaper and vaguer at the same time.
Cheaper than compacting.
Two habits that keep sessions inside the context window instead of relying on the summariser to rescue them.
Frequently asked.
Quick follow-ups people search after this question.
Q · 01 Does auto-compact mean I've hit a usage limit? +
Q · 02 Does compaction lose information? +
CLAUDE.md or a file, where it's re-read rather than remembered.