🌏 中文版
If you run Claude Code on a 1M-context model, this post answers one question: should you lower the auto-compact threshold to 400K? My answer is yes. Eleven days in, I saw none of the side effects I feared. There are two cases where you shouldn't, covered below.
Why the default is expensive
On 1M-context models, Claude Code by default waits until about 967K tokens before it compacts automatically. The cost isn't the compaction itself but everything before it: every message resends the whole conversation history, so even a one-line reply at 900K tokens is a request of nearly a million tokens.
Claude Code team member Lydia Hallie explained this in a post on October 9, and cleared up some common confusion:
- Auto-compact does summarize. When it runs, the whole conversation is replaced by a short summary; it does not keep the last 1M tokens.
- The ~967K figure applies only to 1M models.
- Compaction itself is one request that reads about as many tokens as the message you sent right before it, mostly cache reads when the cache is warm.
- History is mostly read from cache, which is much cheaper, so it's usually fine while the cache is warm. But those tokens still count toward your usage and add up as the conversation grows.
/autocompact 400k makes the summary happen at 400K, so no single message gets more than about half as large. She credits @rohit3a with finding the problem; her post is the follow-up explanation.
How to set it
In Claude Code, type:
/autocompact 400k
Details you'll run into:
- Valid values range from 100K to 1M;
200000,500kand1Mall work. Anything outside the range errors out. - 400K only matters on 1M models. Claude Code uses the smaller of your setting and the model's context window, so it changes nothing on a 200K model (SpecWeave's write-up).
- The command saves the value to your user settings, per model (since v2.1.288; before that it was one value for all models).
/autocompact autoreturns to the default.- For a single launch, use the flag:
claude --autocompact 400k.
When several sources are set, precedence from highest to lowest is the CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable, the launch flag, /autocompact and settings files, then the model default. The environment variable is the confusing one: while it has a value, /autocompact only reports that it's overridden and changes nothing, and it accepts bare integers only, so 500k gets read as 500 and clamped to the minimum. If you set it and see no effect, run /autocompact with no argument; it shows the current window and where it came from. See wmedia.es's breakdown and the official docs.
My 11 days
I switched to 400k after Lydia's post as she suggested, used it for 11 days straight, then looked back at the numbers. Two conclusions:
- Side effects were small. On the kind of work I do, there was no noticeable increase in cases where the model redid work or needed my correction because details got compressed away.
- The savings were clear. About 16–22% less usage.
One data point to compare: @wholyv's post estimates that setting 400k earlier would have saved about 29% of their weekly usage. The two numbers were measured differently and can't be compared directly, but the direction agrees and the magnitude is close.
Limits of this result
This is one person and one kind of task. I had no control group and only 11 days, so "no significant side effects" really means "none I noticed," not proof. If your work involves chasing one complex bug for hours, or needs to look back at verbatim output from hundreds of turns ago, your results may differ.
Claude Code itself recommends auto. The /autocompact help text says auto is a window tuned for your model and "strongly recommended for the best cost and performance," and when it detects an override it warns "Overriding auto may result in high token usage, especially when resuming long sessions" (source). The logic: compacting earlier means compacting more often, and each compaction is a request that reads the entire history. If the cache has gone cold by then (say you were away for a long break), that one costs more than it would with a warm cache. So 400k isn't always a win; it pays off when your sessions are long and regularly pass 400K. Community accounts also say the Claude Code team treats 400K as an experimental threshold, to start from and then adjust per task (relayed here).
Summaries always lose something. Verbatim content becomes a summary; tool output and intermediate reasoning are not kept.
What to do
- Run
/autocompactfirst to see your current value and its source before changing anything. - If you work on everyday tasks and your sessions often run long, set
/autocompact 400kand watch usage and rework for a week or two. - For investigations that need to look back at earlier output, temporarily raise it to 600k–700k and switch back afterward.
- Don't keep requirements and architecture decisions only in the conversation. Put them in CLAUDE.md or task docs and lock critical behavior with tests, so the model can recover from the project itself when a summary drops details.
- If the setting seems to have no effect, check whether
CLAUDE_CODE_AUTO_COMPACT_WINDOWis set somewhere else.
References
- Lydia Hallie: explanation of auto-compact and /autocompact 400k (X, 2026-10-09)
- Kai: relaying the Claude Code team's 400K experiment threshold (X)
- Lxyv: estimate of 29% weekly usage saved (X)
- SpecWeave: Claude Code auto-compact — compact at 400K to save usage
- wmedia.es: Claude Code auto-compact — who decides your context window
- Claude Code docs: Explore the context window