claude-code - 💡(How to fix) Fix [Feature] expose autoCompactWindow / 'until auto-compact' percentage to statusLine stdin

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…

statusLine command hooks receive context_window.used_percentage, but that's calculated against the model's full window (e.g. 1 000 000 tokens for extended-context Sonnet) — not against the user's effective autoCompactWindow setting. This makes it impossible for statusLine plugins to display the same "X% until auto-compact" value Claude Code's own UI shows.

Root Cause

The user-facing autoCompactWindow setting is the only honest signal of how much context the session will tolerate before auto-compaction reshapes it. Every statusLine plugin in the ecosystem that draws a context bar is currently misreporting against the wrong denominator for users who've narrowed their effective window — which is precisely the population that cares most about the bar.

Fix Action

Workaround

Plugins can require users to also set an env var (e.g. HANDOFF_EFFECTIVE_MAX_TOKENS=400000) duplicating the autoCompactWindow value, then compute against current_usage.total_input_tokens / max. This works but duplicates configuration the harness already has.

Code Example

{
  "context_window": {
    "context_window_size": 1000000,
    "effective_context_window_size": 400000,
    "used_percentage": 35,
    "until_auto_compact_percentage": 4
  }
}
RAW_BUFFERClick to expand / collapse

Summary

statusLine command hooks receive context_window.used_percentage, but that's calculated against the model's full window (e.g. 1 000 000 tokens for extended-context Sonnet) — not against the user's effective autoCompactWindow setting. This makes it impossible for statusLine plugins to display the same "X% until auto-compact" value Claude Code's own UI shows.

Repro

  1. Set "autoCompactWindow": 400000 in ~/.claude/settings.json (or use the default — same shape).
  2. Use any documented statusLine example that reads .context_window.used_percentage.
  3. Run a session until CC's own UI shows e.g. "4% until auto-compact" (i.e., 96% of your effective window).
  4. The plugin renders ~35% because used_percentage = current_tokens / 1_000_000.

CC's own UI clearly computes the auto-compact percentage internally; statusLine plugins have no access to it.

Requested change

Expose one of these in the statusLine stdin payload:

{
  "context_window": {
    "context_window_size": 1000000,
    "effective_context_window_size": 400000,
    "used_percentage": 35,
    "until_auto_compact_percentage": 4
  }
}

Either effective_context_window_size (so plugins can compute the ratio) or until_auto_compact_percentage (so plugins can display it directly) would close the gap. Both would be ideal.

Why this matters

The user-facing autoCompactWindow setting is the only honest signal of how much context the session will tolerate before auto-compaction reshapes it. Every statusLine plugin in the ecosystem that draws a context bar is currently misreporting against the wrong denominator for users who've narrowed their effective window — which is precisely the population that cares most about the bar.

Workaround

Plugins can require users to also set an env var (e.g. HANDOFF_EFFECTIVE_MAX_TOKENS=400000) duplicating the autoCompactWindow value, then compute against current_usage.total_input_tokens / max. This works but duplicates configuration the harness already has.

Context

Surfaced while building a context-fill-triggered handoff plugin: https://github.com/jasonm4130/claude-skills/tree/main/plugins/handoff

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING