Claude Corner
Need to Choose When Claude Code Compacts? Use /autocompact.
By Steven Sorensen ยท 27 Nov 2026

At a glance
- One built in command sets how full the context window gets before Claude Code compacts on its own.
- A launch flag lets you try a size for one session without changing your saved settings.
- One word returns you to the window Claude Code tunes for your model.
By default, Claude Code waits until the context window is nearly full before it compacts a long session on its own. If you would rather set that line yourself, /autocompact is the built-in command for it.
Why it matters
Anthropic's model configuration guide says that when you have not set a window, Claude Code compacts when the conversation reaches the model's context limit, and models with a native 1M window compact at about 967K tokens by default. The command takes a token count and sets how full the window gets before that automatic pass runs. Compaction replaces the history with a summary, so pick a size, try it, and keep it only if it suits how you work.
How to set the compaction point
- Inside a session, run
/autocompactwith no value. The commands reference says this opens a dialog showing the current window. - Run
/contextto see what is filling the window, as the commands reference suggests when a conversation gets long. - Run
/autocompact 500kor another size. The guide says Claude Code saves it under the current model and applies it to the session you are in. - Use 100K tokens or more. The guide accepts a plain count such as
200000, akorMsuffix such as500k, or a bare number from 100 to 1000 read as thousands, and caps any value at the model's context window. - To try a size for one launch, start with
claude --autocompact 500k. The guide says the flag overrides your saved setting for that launch without changing it. - To go back, run
/autocompact auto, which the guide says returns to the window tuned for your model.
# We have not run this script end to end on every platform.
# Inside a session, show the current window.
/autocompact
# See what is filling the context right now.
/context
# Set a window for the current model.
/autocompact 500k
# Return to the window tuned for your model.
/autocompact auto
# From your shell, try a size for one launch only.
claude --autocompact 500k
Gotchas
- It is saved per model. The guide says the value goes under the current model in your user settings, so switching models can mean a different window.
- Managed settings can win. If a higher priority scope sets its own window, the guide says the command saves your value but the session keeps that scope's window, and it tells you so. The launch flag is not preempted that way.
- Some things fade after a summary. The context window guide says path scoped rules and nested CLAUDE.md files loaded during the session get summarized away, while skill bodies are added back, so check those rules after a compaction.
- Older builds behaved differently. The command needs v2.1.221 or later, and before v2.1.288 it saved one window for every model.
To watch how full the window is getting, put it in the status line with Never Sure How Full Claude's Context Is? Put It in Claude Code's Status Line.
Sources:
- Model configuration, Claude Code docs
- Explore the context window, Claude Code docs
- Commands, Claude Code docs
- CLI reference, Claude Code docs
Recommended AI prompt
Copy this paragraph into ChatGPT, Claude, Gemini, Grok, or whatever AI you use.
I use Claude Code for long sessions and want to set the automatic compaction window with /autocompact. Ask me which model I use, how long my sessions usually run, and which rules or notes I need Claude to keep after a summary. Then suggest a starting window of at least 100K tokens, a plan to test it for one launch with the command line flag before I save it, and a short checklist for deciding whether to keep it or return to the default.