Claude Code Auto Compact

Check why Claude Code compacted near 400K, what survived the summary, and when to use /autocompact 1M for a long codebase review.

Published

Claude Code Auto Compact

If Claude Code summarized your session halfway through a codebase review, run /autocompact to see the window it was using. Anthropic is rolling out a default that compacts near 400K tokens on most current models with a 1M context window. If your next decision depends on comparing source files side by side, use /autocompact 1M on a supported model. If you have finished that comparison and are ready to edit, this may be exactly the right time to compact.

Why a 1M session can compact near 400K

The context window is how much information the model can work with at once. It includes your instructions, the files Claude has read, tool output and the conversation itself. Tokens are the units used to measure that material. The auto-compact window sets how full the workspace gets before Claude Code replaces the conversation with a structured summary. Picture a drafting table. Its dimensions determine how many drawings fit. You can put away a finished set and leave a page of decisions on the table while there is still room to work. How a context window works

The December 1 release of Claude Code 2.1.334 added Auto-compact window to /config. It shows and changes the same setting as /autocompact. The release notes describe the move toward 400K as a rollout. One reason two people can see different behavior is how their sessions started. For example, resuming a conversation already past 400K gives it a 1M window until its next compaction. A conversation left idle can also compact below the size you chose. Anthropic’s model-specific thresholds and exceptions

What Claude has in front of it afterward

The session continues with a summary that carries forward your requests and key code snippets. An exact exception message or a constraint you mentioned early can lose its detail. The project-root CLAUDE.md instruction file, rules that apply across the project, and a plan written in plan mode load again from disk. Instructions in subdirectories load again as Claude works with the relevant files. What survives compaction

Loose history sheets become a bound summary beside a separate project rules manual.
The next turn gets a summary of the discussion. Project-wide instructions return from disk.

Claude Code also rereads up to five files it previously read or edited, starting with the most recently modified. For a file over 5,000 tokens it gets a path reference instead of the contents. Suppose your patch depends on the distinction between an absent field and an empty string. Put that distinction in a test. Even a good summary that says “preserve compatibility” gives the next developer too little to check.

How to inspect, set or trigger compaction

What you needWhat to do in the terminal
See what is taking up space nowRun /context for the breakdown of the current conversation.
Check when this model will compactRun /autocompact without a value. In a resumed conversation, wait for Claude’s first reply before checking.
Change the window for this modelIn /config, choose Auto-compact window. The separate Auto-compact toggle controls whether automatic compaction is enabled.
Use the full supported windowRun /autocompact 1M. On your machine this saves the choice for later sessions on that model version. Use /autocompact auto to return to its tuned default.
Change it for one launchStart with claude --autocompact 1M on a 1M model. Your saved preference stays in place for subsequent launches.
Summarize at a checkpoint nowRun a focused command such as /compact Keep the parser contract, failing test name and remaining callers.

For a default across models, set the top-level "autoCompactWindow": 200000 in ~/.claude/settings.json, substituting your chosen token count. The window is capped at model capacity. A matching per-model entry under modelSettings takes precedence in the same file. That is where the interactive command saves a personal choice. Settings reference

Two equal rails show automatic compaction near 400K and compaction at about 967K with the full 1M window selected.
On a current native 1M model using the new default, the two settings leave different amounts of history in play. Anthropic puts the full-window compaction point at about 967K.

Five sessions where the setting changes the work

1. A maintainer midway through a refactor. You have traced every caller of an old parser and agreed on the replacement contract. The next few hours are mechanical edits. Write down the callers still to migrate, the compatibility test and the one caller that needs special handling. Run the focused /compact command above, then ask Claude which caller it would change next and why. You can catch a missing constraint before it spreads across the patch. This is the highest-value use of manual compaction because you know exactly where investigation ends and implementation starts. Clearing and compacting during coding work

2. A reviewer tracing a large codebase. Suppose you need to decide whether two services can safely retry the same payment. The answer depends on the producer, queue configuration, consumer and database constraint agreeing about the same identifier. Start the review with the full window if those reads need to coexist. Ask for the file and symbol at each handoff, and verify them while the evidence is together. Once the review is recorded, a shorter context can carry the fix. Keeping more history available buys you comparison room. It still takes a deliberate file read to bring each component into the conversation.

3. A platform lead standardizing terminal reviews. If the release team routinely does that cross-service work, give its reviewers the same starting window. Anthropic’s example for a managed settings file targets a specific model version:

JSON
{
  "modelSettings": {
    "claude-opus-5-5": {
      "autoCompactWindow": 1000000
    }
  }
}

Add an entry for each intended 1M model version. The managed entry takes priority over a developer’s saved preference. A one-launch --autocompact flag or an applicable CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable can still override it. Have reviewers check the effective window when reporting a discrepancy. That gives the team a reproducible starting point for investigating the same change.

4. An on-call engineer handing over a failing test. Before compacting, record the reproduction command, the exact error and the last known good revision in the incident notes. Ask the summary to retain the remaining hypotheses. The next shift can rerun the failure even if the wording of the original terminal output drops out. For standing repository instructions, use the project setup guide.

5. A developer investigating an apparent model regression. If Claude suddenly suggests a fix you ruled out earlier, check whether the session compacted between those turns. Point Claude back to the file or test that rules out the fix and see whether the answer changes. That small check gives you evidence for a model behavior investigation before you repeat the whole session.

What this does to usage limits

An auto-compact warning tells you about space in this conversation. Check /usage for your subscription’s usage breakdown. Anthropic says earlier compaction makes later requests smaller, which can reduce tokens used in long sessions. The summary itself also consumes tokens because Claude reads the conversation to produce it. Increasing the window lets more material stay available for the next request. It gives you no additional plan allowance. If the next task is unrelated, /clear starts fresh without paying for a summary. Anthropic’s guide to costs and usage

Two tools worth building around the handoff

Build the handoff checker first. A maintenance team could use a small tool that reads a developer’s checkpoint note and verifies that the named files and test targets still exist. Its first version could flag missing references and print a focused /compact prompt for the developer to review. The reason to pay would be catching a broken handoff before another engineer spends time reconstructing it. Start with one repository and its test runner. A checker can establish that a test exists while still missing that it checks the wrong behavior.

Build a settings inspector for platform teams. A local utility could show the model version, the relevant user and managed entries, and any environment override beside a value copied from /autocompact. A support engineer could attach that short report to a ticket without sharing conversation contents. The native dialog already answers the individual developer’s question. The paid case depends on teams needing to explain differences across machines often enough to justify maintaining a tool as settings change.

How do I see the context in Claude Code?

Run /context to see what occupies the current session. Run /autocompact separately to see the window that triggers its automatic summary.

How do I reduce Claude Code context window usage?

At a natural checkpoint, run /compact with the details the next phase needs. For a completely separate job, use /clear. To trigger future automatic summaries sooner, choose a smaller auto-compact window.

What happens if I run out of context window in Claude Code?

With auto-compaction enabled, Claude Code normally summarizes as the conversation approaches its configured window and continues. If a single file or tool result immediately fills the space again, repeated compaction can stop with an error. Narrow the read or tool output before continuing. How Claude Code handles a full context

For help building a handoff checker around your team’s repositories and test runners, see AI automation services.

Published
Category
Build
Related Articles
Ponytail Claude Code Plugin: How It Works and When to Turn It Off

Ponytail Claude Code Plugin: How It Works and When to Turn It Off

See how Ponytail chooses a smaller patch, install it in Claude Code or Codex, and compare the project’s code savings with JetBrains’ independent test.Dec 3, 2026Build
Building a Voice Agent With the Gemini Live API

Building a Voice Agent With the Gemini Live API

Choose a thinking level, open an audio session, and keep callers talking during a lookup. Includes Gemini 4 Live pricing, phone integrations and limits.Dec 3, 2026Build
Vercel MCP

Vercel MCP

Connect Claude Code or Codex to Vercel, diagnose a failed build, call a second model, and set up team access with Claude Enterprise-managed auth.Dec 3, 2026Build
LobeChat Is Now LobeHub: What It Does, What It Costs, and How to Start

LobeChat Is Now LobeHub: What It Does, What It Costs, and How to Start

Connect multiple models in LobeHub, add a provider key, and start a local Docker install. Check the license before distributing a modified app.Dec 3, 2026Build
AWS Kiro: What It Is, What It Costs, and How to Start

AWS Kiro: What It Is, What It Costs, and How to Start

How AWS Kiro turns a feature request into a spec, which models and plans you can use, and how to start in the IDE or terminal.Dec 3, 2026Build
What Is OpenRouter? How It Works and How to Start

What Is OpenRouter? How It Works and How to Start

Get an OpenRouter API key, make your first request, and see how provider fallback and data settings change which models your app can use.Dec 3, 2026Build
Antigravity CLI: What It Is, What It Costs, and How to Start

Antigravity CLI: What It Is, What It Costs, and How to Start

Install Google’s agy terminal agent, review your first edit, and run a headless prompt. See who moved from Gemini CLI and what Google’s terms permit.Dec 3, 2026Build
Claude Code Channels

Claude Code Channels

Message a running Claude Code session from your phone. Set up Telegram, connect a Discord team room, and choose who can send requests or approve tools.Dec 2, 2026Build
Newsletter

One letter, every Sunday.Working systems, not hot takes.

Weekly. No spam. Unsubscribe anytime.