CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS
Updated by Alex Sorokoletov
CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS is a Claude Code environment variable: Sets the minimum conversation size, in tokens, before idle compaction runs. The value is floored at 100,000 and defaults to 200,000 when unset. Added in v2.1.290 and still present in v2.1.332. It is listed in the official reference.
| Status | Present in v2.1.332 |
|---|---|
| Added | Added in v2.1.290 |
| Category | Context and compaction |
| Official docs | Listed |
How to set it
For one session, export it in the shell that starts Claude Code:
export CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS=<value>
claudeTo apply it to every session, add it to the env object of a settings file:
// ~/.claude/settings.json
{
"env": {
"CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS": "<value>"
}
}Release notes that mention it
- Claude Code "Compacted while idle": What Idle Compaction Does and How to Turn It Off
- Claude Code Version Tracker: Undocumented Env Vars, Feature Gates & Models
- claude-code-env-vars-v2-1-299
- claude-code-env-vars-v2-1-290
Related variables
CLAUDE_AFTER_LAST_COMPACT: Request only conversation logs after last compaction.CLAUDE_CODE_AUTO_COMPACT_WINDOW: Sets the auto-compact window in tokens, 100k to 1M, capped at the model's context window.CLAUDE_CODE_AUTO_MODE_COMPACT_THREAD_RULE: When set, enables the compact thread rule for auto-mode project threads; while off, thread handling stays on the original path.CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS: Max tokens for file read output.CLAUDE_CODE_MAX_CONTEXT_TOKENS: Sets an explicit ceiling on the context window size used during a session.CLAUDE_CODE_MAX_OUTPUT_TOKENS: Maximum output tokens; validated per-model.CLAUDE_CODE_SLEEP_COMPACT: When set, enables sleep compaction, which compacts the conversation while the session sits idle.CLAUDE_CODE_SLEEP_COMPACT_AFTER_MS: Milliseconds to wait after a turn before idle sleep compaction runs, clamped between 60000 and 210000; defaults to 150000.
Frequently asked questions
What does CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS do?
Sets the minimum conversation size, in tokens, before idle compaction runs. The value is floored at 100,000 and defaults to 200,000 when unset.
Which Claude Code version has CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS?
Added in v2.1.290 and still present in v2.1.332.
How do I set CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS?
Export it before starting Claude Code (export CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS=value), or add it to the "env" object in ~/.claude/settings.json to apply it to every session.
All variables, searchable: Claude Code environment variables.