Status line doesn't refresh context tokens after /clear

Resolved 💬 6 comments Opened Dec 20, 2025 by patnrv Closed Mar 1, 2026

Description

Custom status line showing context window usage (total_input_tokens, total_output_tokens) doesn't update after running /clear. The old token counts persist until the next message exchange, even though the context has been cleared.

Steps to Reproduce

  1. Configure a custom status line in ~/.claude/settings.json that displays context token usage:

``json
{
"statusLine": {
"type": "command",
"command": "input=$(cat); total_input=$(echo \"$input\" | jq -r '.context_window.total_input_tokens'); total_output=$(echo \"$input\" | jq -r '.context_window.total_output_tokens'); context_size=$(echo \"$input\" | jq -r '.context_window.context_window_size'); total_tokens=$((total_input + total_output)); percentage=$((total_tokens * 100 / context_size)); printf \"Context: %d/%dk (%d%%)\" \"$total_tokens\" \"$((context_size / 1000))\" \"$percentage\""
}
}
``

  1. Have a conversation that accumulates tokens (e.g., 50k+ tokens used)
  2. Run /clear to clear the conversation
  3. Observe that the status line still shows the old token count/percentage

Expected Behavior

After /clear, the status line should immediately refresh and display the reset token counts (close to 0 or whatever the new baseline is after clearing).

Actual Behavior

The status line retains the old token values from before the clear. It only updates after the next message exchange.

Environment

  • Claude Code CLI
  • macOS
  • Status line configured with type: "command"

Additional Context

The status line documentation states it updates "when conversation messages change." The /clear command does change the conversation (by clearing it), so it should trigger a status line refresh with the updated context window values.

🤖 Generated with Claude Code

View original on GitHub ↗

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