[FEATURE] Auto-refresh status line data after /compact command

Resolved 💬 3 comments Opened Dec 21, 2025 by michelsdev Closed Dec 21, 2025

Feature Request

After running /compact, the JSON data provided to the status line still contains old/stale context usage values until the next user message. This JSON should be refreshed automatically after /compact.

Important Clarification

We are using a custom status line script (via /statusline command) that reads the JSON data provided by Claude Code. The issue is NOT with our script - the issue is that Claude Code's JSON data is not refreshed after /compact.

Our script reads these fields from YOUR JSON:

{
  "context_window": {
    "current_usage": {
      "input_tokens": ...,
      "cache_creation_input_tokens": ...,
      "cache_read_input_tokens": ...
    }
  }
}

These values remain stale after /compact until a new API call is made.

Current Behavior

  1. User has high context usage (e.g., 87% | 175k tokens)
  2. User runs /compact to reduce context
  3. Claude Code's JSON still contains old values
  4. Status line (reading this JSON) shows stale data (87% | 175k)
  5. Only updates after sending a new message triggers a new API call

Expected Behavior

After /compact completes, Claude Code should refresh the JSON data (context_window.current_usage.*) sent to status line scripts with the new, reduced context values.

Why This Matters

  • User confusion: After compacting, users expect to see the result immediately
  • Poor UX: Current behavior makes it seem like /compact didn't work
  • Workaround is wasteful: Users have to send a dummy message ("ok") just to trigger a JSON refresh, which consumes tokens unnecessarily

Proposed Solution

After /compact completes, trigger an internal refresh of the context_window data in the JSON payload sent to status line scripts.

Environment

  • Claude Code version: 2.0.75
  • Feature: Custom status line via /statusline (official feature since v1.0.71)
  • Reading: context_window.current_usage.* fields from Claude Code's JSON

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗