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.310. It is listed in the official reference.
| Status | Present in v2.1.310 |
|---|---|
| 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: Controls the token window threshold at which automatic context compaction kicks in.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.DISABLE_AUTO_COMPACT: Disable automatic compaction only (manual /compact still works).DISABLE_CLAUDE_CODE_SM_COMPACT: Disable session memory compaction.DISABLE_COMPACT: Disable all compaction (manual + auto).
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.310.
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.