chat-recall

Context left until auto-compact: what the number counts

Claude Code shows you a percentage and never explains it. It is counting down to the moment your conversation gets summarized and the original stops being in front of the model.

What the number counts

The status line shows % until auto-compact, and some setups show % context used instead. Both describe the same thing from opposite ends: how much of the model's context window this session has filled, and how much room is left before Claude Code summarizes everything so far and carries on from the summary.

Below a threshold it changes tone and says Context low with the remaining percentage. Shortly before it fires you get the real warning:

the warning worth reading
Autocompact will trigger soon, which discards older
messages. Use /compact now to control what gets kept.

That sentence is doing more work than it looks like. Compaction happens either way; running it yourself is the only version where you choose what survives.

Why it falls faster than you expect

Every session starts with a fixed cost before you type anything: the system prompt, every tool definition from every MCP server you have registered, and the CLAUDE.md files for the project. Add four MCP servers with a few dozen tools between them and a meaningful slice of the window is spent at startup, on every single session.

After that, the things that move the number fastest are rarely your messages. Reading a large file puts the whole file in context. A test run that fails puts the whole output there. A search across a big repository can cost more than an hour of conversation.

Moving the threshold

/autocompactOpens the window picker inside a session. It reports the current window and what set it, so you can see when something else is overriding your choice.
--autocompact <auto|tokens>The same setting as a launch flag. auto lets Claude Code size the window to the model; a number pins it.
CLAUDE_CODE_AUTO_COMPACT_WINDOWThe environment variable. It wins over the setting, and Claude Code tells you so when you try to change the window while it is set.
autoCompactWindowThe settings key, for when you want the choice to persist rather than live in one shell.

Turning it off is the expensive option

You can. DISABLE_AUTO_COMPACT in the environment, or autoCompactEnabled in settings, and the status line switches to auto-compact is off. Claude Code is direct about the consequence: without it you hit the context limit and lose the conversation instead, and your only remaining move is running /compact by hand before you get there.

There is a related setting that does not turn anything off — Claude Code can precompute the summary in the background before it is needed, which only applies while auto-compact is on. The pause you notice at the boundary is what that removes.

What reaching zero actually does

It writes one record into your transcript file and keeps going in the same session:

from a real transcript
{"type":"system","subtype":"compact_boundary",
 "content":"Conversation compacted",
 "compactMetadata":{"trigger":"manual","preTokens":205229}}

Everything before that line is still in the file. In the session I pulled that from, the boundary sits at line 1588 of 2257 — so 1587 records of conversation are on disk, in order, after the model stopped being able to see them. The next record is a user message flagged isCompactSummary, and that summary is what the model reads from then on.

So the percentage is not counting down to deletion. It counts down to the point where the detail moves out of the conversation and into a file, where finding it again takes a search.

Three things that buy you room

  • Start a new session for a new task. The fixed startup cost is paid either way, and a fresh window beats a summarized one for work that shares nothing with what came before.
  • Unregister MCP servers you are not using in this repo. Their tool definitions are in the prefix of every session whether you call them or not.
  • Run /compact yourself, with instructions, at a point you choose instead of one the token count chooses. What to put in those instructions.

Index your sessions free What a compact costs you

Questions

What does "% until auto-compact" mean in Claude Code?It is the share of the model's context window this session has left before Claude Code summarizes the conversation so far and continues from that summary. Some setups display the same measurement as "% context used" instead. Below a threshold it switches to a "Context low" warning, and shortly before it fires it tells you to run /compact yourself to control what gets kept.
How do I see how much context is left in Claude Code?The status line carries it continuously. Running /autocompact also reports the current auto-compact window and which input decided it, which is the faster way to check when an environment variable or a setting is overriding what you thought you configured.
Can I change when auto-compact triggers?Yes, three ways. Run /autocompact inside a session to pick a window, launch with --autocompact <auto|tokens>, or set autoCompactWindow in settings. The environment variable CLAUDE_CODE_AUTO_COMPACT_WINDOW takes precedence over the setting, and Claude Code says so when you try to change the window while it is set.
Can I turn auto-compact off?Yes, with DISABLE_AUTO_COMPACT in the environment or autoCompactEnabled in settings, and the status line then reads "auto-compact is off". Claude Code warns that you will hit the context limit and lose the conversation instead, so the practical version is running /compact manually before you get there.
Why does my context drop so quickly?Two reasons. Every session pays a fixed cost before your first message for the system prompt, the tool definitions of every registered MCP server, and the project's CLAUDE.md files. After that, reading a large file, a failing test run or a wide repository search each put their full output into the window, and those cost far more than the messages you type.
Does auto-compact delete my conversation?No. It writes a compact_boundary record into the session's .jsonl file and keeps appending to the same file. Every message before that boundary stays on disk in order. The model stops seeing them; the file still has them.

More notes

Compacting conversation: what Claude Code keeps and dropsWhat auto-compact does to a long session, why the assistant starts contradicting itself afterwards, and how to get the lost detail back instead of retyping it.
/clear vs /compact in Claude CodeOne summarizes the conversation and keeps going. The other starts a fresh one. What each does to the transcript on disk, and which to reach for.
Compact instructions: tell /compact what to keepCompaction decides what survives unless you decide for it. Passing instructions to /compact, and the PreCompact hook that supplies them every time.