Feature request: configurable auto-compact threshold (e.g. autoCompactThreshold in settings.json)
Summary
Currently there is no way to configure when auto-compact triggers. Claude Code manages context automatically, but users cannot set a threshold to control this behavior.
Current behavior
- Auto-compact fires at an undocumented internal threshold with no user control
- No setting in
settings.json, no environment variable, no CLI flag - The only option is manual
/compact
Requested behavior
Add a configurable threshold in settings.json, for example:
{
"autoCompactThreshold": 0.9
}
Or alternatively an environment variable: CLAUDE_AUTOCOMPACT_THRESHOLD=90
This would let users define at what context percentage auto-compact triggers (e.g. 80%, 90%).
Why this matters
Users working on large, long-running sessions need to predict and control when compaction happens. An unexpected auto-compact mid-task can disrupt workflow. A configurable threshold gives users control without requiring manual /compact every session.
Alternatives considered
Implementing a Stop hook that reads context % and triggers /compact — this works as a local workaround but requires custom scripting and is not as clean as a native setting.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗