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. Idle compaction itself is controlled by a feature gate with off, log, and compact modes and fires at 90% of the threshold by default. Added in v2.1.290. Added in v2.1.290 and still present in v2.1.294. It is listed in the official reference.
| Status | Present in v2.1.294 |
|---|---|
| Added | Added in v2.1.290 |
| Category | Authentication |
| 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 Version Tracker: Undocumented Env Vars, Feature Gates & Models
- claude-code-env-vars-v2-1-290
Related variables
CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS: Max tokens for file read output.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD: Works alongside CLAUDE_CODE_IDLE_THRESHOLD_MINUTES to gate when the idle-return prompt appears.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.MAX_MCP_OUTPUT_TOKENS: Max tokens for MCP tool output.MAX_THINKING_TOKENS: Likely controlled via API settings now.CLAUDE_BG_SOCKET_TOKENS_PATHCLAUDE_CODE_TOTAL_TOKENS_REMINDER
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. Idle compaction itself is controlled by a feature gate with off, log, and compact modes and fires at 90% of the threshold by default. Added in v2.1.290.
Which Claude Code version has CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS?
Added in v2.1.290 and still present in v2.1.294.
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.