/clear does not reset context_window.total_input_tokens in statusline JSON

Resolved 💬 3 comments Opened Jan 3, 2026 by mattharvill Closed Jan 7, 2026

Description

When using /clear to reset a Claude Code session, the context_window.total_input_tokens value passed to custom statusline scripts does not reset. The token count persists (and even slightly increases) after clearing, while it correctly resets to 0 when starting a completely new Claude Code process.

Steps to Reproduce

  1. Configure a custom statusline script that displays token counts:
# ~/.claude/settings.json
{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh"
  }
}
  1. Statusline script reads from JSON input:
INPUT_TOKENS=$(echo "$JSON" | jq -r '.context_window.total_input_tokens // 0')
CONTEXT_SIZE=$(echo "$JSON" | jq -r '.context_window.context_window_size // 200000')
echo "DEBUG: ${INPUT_TOKENS}/${CONTEXT_SIZE} tokens"
  1. Use Claude Code until token count is high (e.g., 430k tokens)
  2. Run /clear
  3. Observe token count in statusline

Expected Behavior

After /clear, total_input_tokens should reset to a low value (~10-20k for system prompt + CLAUDE.md).

Actual Behavior

  • Before /clear: 430543/200000 tokens
  • After /clear: 430707/200000 tokens (increased slightly, not reset)
  • Starting fresh Claude process: 0/200000 tokens (correct)

Environment

  • macOS (Darwin 25.2.0)
  • Claude Code CLI
  • VS Code integrated terminal (also reproduced in standalone terminal)

Impact

Users relying on statusline context warnings cannot use /clear to reset their session - they must quit and restart Claude Code entirely.

Workaround

Quit Claude Code process completely and start a new one (don't rely on /clear).

View original on GitHub ↗

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