claude-code - 💡(How to fix) Fix CLAUDE_AUTOCOMPACT_PCT_OVERRIDE in settings.json env block silently ignored by autocompact logic

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

Autocompact threshold is not respected. The only workaround is to export the variable in the shell before launching Claude Code (export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=75 in .bashrc/.zshrc).

RAW_BUFFERClick to expand / collapse

Bug

Setting CLAUDE_AUTOCOMPACT_PCT_OVERRIDE in the env block of settings.json has no effect on the autocompact threshold. The variable is visible to subprocess tool calls (e.g. Bash) but is not applied to the Claude Code application's own autocompact logic.

Steps to reproduce

  1. Add "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "75" to the env section of ~/.claude/settings.json
  2. Start a long session until context exceeds 75%
  3. Observe: autocompact does not fire
  4. Run Bash(echo $CLAUDE_AUTOCOMPACT_PCT_OVERRIDE) — confirms subprocess sees 75
  5. Session continues past 86% with no autocompact trigger

Expected behavior

Either:

  • The env block in settings.json should apply to app-level configuration knobs (including autocompact threshold), not only to subprocess invocations, OR
  • The docs/settings UI should clearly distinguish between "subprocess env vars" and "app configuration vars" and provide a separate mechanism for the latter

Actual behavior

Autocompact threshold is not respected. The only workaround is to export the variable in the shell before launching Claude Code (export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=75 in .bashrc/.zshrc).

Environment

  • Claude Code CLI (headless Linux server)
  • Model: claude-sonnet-4-6
  • settings.json env injection confirmed working for subprocess calls
  • Context reached 86% (172.6k/200k) without autocompact firing despite threshold set to 75%

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Either:

  • The env block in settings.json should apply to app-level configuration knobs (including autocompact threshold), not only to subprocess invocations, OR
  • The docs/settings UI should clearly distinguish between "subprocess env vars" and "app configuration vars" and provide a separate mechanism for the latter

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING