Claude Code Auto-Compact: Set It to 400K and Save Your Quota

Auto-compact is meant to keep a long Claude Code session usable. On a 1M-context model the default threshold is so high that you pay for a very large context on every message first. Here is what the setting does, and how to choose a smaller window without losing the decisions that matter.

Published: October 2026 Reading time: 6 min Topic: Usage Limits

What auto-compact does

Every Claude Code conversation has a context window. When the conversation reaches the auto-compact threshold, Claude Code summarizes older history and continues with that summary instead of the full transcript. This is called compaction.

Compaction is not the same as starting over. The session continues, but older detail is replaced by a shorter summary. You can also run /compact yourself when you want to summarize on demand, and /clear when you want a new, clean context for an unrelated task.

Why the default threshold burns through your limit

Until compaction happens, every message sends the whole conversation again. Most of that input is usually read from the prompt cache. Cache reads are cheaper than fresh input, but they still count toward your usage limit.

On 1M-context models the default auto-compact threshold is around 967K tokens. That is close to the top of the window. A long session can therefore keep resending a very large context, turn after turn, before auto-compact steps in.

The expensive part is not one large message. It is the same large context repeated on every turn. A smaller window caps that repeated cost and makes the session compact earlier.

How to set the auto-compact threshold

There are three ways to change the threshold, depending on how you work:

  • In an interactive session: run /autocompact in a current Claude Code version and set the window you want.
  • On the command line: use --autocompact <auto|tokens>. The value is either auto or a token count between 100K and 1M, for example claude --autocompact 400000.
  • As a persistent setting: add autoCompactWindow to ~/.claude/settings.json.
{
  "autoCompactWindow": 400000
}

If /autocompact does not appear in your session, update the CLI with claude update and try again.

We use a window of 400K to 500K. That is our own preference, not a measured optimum. A lower value compacts sooner and produces more summaries; a higher value keeps more raw history but resends more tokens each turn. The trade-off is yours to pick.

Do not let compaction erase your decisions

A summary can drop small details that mattered: a file path, a naming decision, an API constraint, or the reason you rejected an approach. The next turn may still work, but the detail is gone for good.

The fix is to keep decisions in a file, not only in the chat. Ask Claude Code to write the important ones to CLAUDE.md or AGENTS.md as you go. Codex and OpenCode read AGENTS.md; Claude Code reads CLAUDE.md and supports imports, so a single line @AGENTS.md inside CLAUDE.md lets Claude read the same rules.

At the end of a session, a useful prompt is: "Add the decisions we made today, the files involved and the open questions to AGENTS.md." That file survives compaction, a new session and a different agent.

How Foxpit keeps decisions in files

Foxpit has a shared project memory called Beyin. It is not a chat log that disappears when a session compacts; it is a set of files every agent on the project can read.

  • Plain markdown in the repo. Memory lives in .foxpit/memory with [[links]], so decisions and open threads stay reviewable and editable.
  • One memory for every agent. A new session on Claude Code, Codex or OpenCode already knows yesterday's decisions, files and open threads.
  • Notes view and graph. You can browse the same memory in the app instead of searching through old conversations.

Related: if you are already at the limit, read Claude Code usage limit: what to do and save Claude quota with orchestration.

Frequently asked questions

What does auto-compact do in Claude Code?

When a conversation reaches the auto-compact threshold, Claude Code summarizes older history and continues with that summary instead of the full transcript. You can also run /compact yourself, while /clear starts a new, clean context.

What is the default auto-compact threshold?

On 1M-context models the default is around 967K tokens, as Anthropic's Lydia Hallie explained on X. That is close to the top of the window, so a long session can run at a very large context before compaction happens.

How do I set auto-compact to 400K?

Run /autocompact in an interactive session, pass --autocompact 400000 on the command line, or set autoCompactWindow to 400000 in ~/.claude/settings.json. If the command is missing, run claude update.

Does compaction lose information?

Compaction is a summary, so some details can be lost. Write important decisions, file paths and constraints to CLAUDE.md or AGENTS.md so they survive compaction and later sessions.

Keep the decisions, not just the summary.

Download Foxpit Shared Agent Memory