Skip to content
BENIBIX Learn

CLAUDE_CODE_AUTO_COMPACT_WINDOW

AI⌨️ Claude CodeConfiguration

Also known as CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable

It sets how full a chat gets before it is squeezed.

Think of it like

It is like you pick the size of a box. Then you fill it.

Example

Jack runs on a 1M model, but long chats get slow and costly. He sets the window to 300,000, so chats are squeezed well before that.

Why it matters

A huge window can cost a lot per request. A smaller one keeps each turn lean.

Definition

CLAUDE_CODE_AUTO_COMPACT_WINDOW sets how many tokens a chat can hold before Claude Code squeezes it. Pick a value from 100,000 to 1,000,000 tokens. A short form such as 200k needs version 2.1.304 or later. A smaller window squeezes the chat sooner and keeps each request smaller.

Example code

bash
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=200000
claude
Squeeze the chat at 200,000 tokens.
The window is the whole bar.

Common mistake

Setting a value below 100,000. That is out of range, so it does not work.

Key takeaways

  1. 1
    100,000 to 1,000,000. Tokens.
  2. 2
    Smaller squeezes sooner. Leaner requests.
  3. 3
    200k form. Needs 2.1.304.

Compare