CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS

Updated by

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.

StatusPresent in v2.1.294
AddedAdded in v2.1.290
CategoryAuthentication
Official docsListed

How to set it

For one session, export it in the shell that starts Claude Code:

export CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS=<value>
claude

To 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

Related variables

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.