[BUG] Status line JSON not updated after /clear — context_window data remains stale

Resolved 💬 3 comments Opened Feb 22, 2026 by virtualian Closed Feb 22, 2026

Description

After running /clear, the status line command continues to receive the previous session's context_window.current_usage token counts. The status line is not updated with fresh (zeroed) data until the first API round-trip in the new session completes.

This means any custom status line displaying context usage (a common use case) shows stale percentages after /clear, which is confusing — the user sees a cleared conversation but the context bar still shows, e.g., 44%.

Steps to Reproduce

  1. Start a Claude Code session with a custom statusLine command that displays context_window.current_usage data
  2. Have a conversation long enough to reach meaningful context usage (e.g., 40%+)
  3. Run /clear
  4. Observe that the status line still displays the pre-clear context percentage
  5. Send a new message — the status line now correctly resets to a low percentage

Expected Behavior

After /clear, the status line should receive an updated JSON payload with zeroed/reset context_window.current_usage values, reflecting the new empty session state.

Actual Behavior

The status line retains stale token counts from the previous session until the next API call triggers a fresh status line update.

Environment

  • Claude Code: v2.1.50
  • Platform: macOS (Darwin 25.4.0)
  • Model: Opus 4.6

Suggested Solutions

  1. Emit a status line update on /clear — When /clear resets the session, push a JSON payload to the status line command with zeroed current_usage fields. This is the most natural fix since /clear is a session-boundary event.
  1. Add a session_id field to status line JSON — Include a session identifier so custom status lines can detect session changes and reset their displayed state independently.
  1. Fire a SessionClear hook event — Emit a hook event (e.g., PostCommand with command /clear) so hook authors can react to session resets. This would also benefit other hook use cases beyond status lines.

Option 1 is the simplest and most direct fix.

View original on GitHub ↗

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