Statusline payload missing context_window data (documented but not present)

Resolved 💬 4 comments Opened Jan 2, 2026 by sammjung Closed Feb 16, 2026

Problem

The statusline documentation describes a context_window object in the JSON payload with fields like:

  • context_window_size
  • total_input_tokens / total_output_tokens
  • current_usage.input_tokens, etc.

However, none of these fields exist in the actual statusline payload. This makes it impossible to display context percentage in a custom statusline using the documented approach.

Actual Payload

Here's what the statusline actually receives:

{
  "session_id": "...",
  "transcript_path": "/Users/.../.claude/projects/.../session.jsonl",
  "cwd": "/path/to/project",
  "model": {"id": "claude-opus-4-5-20251101", "display_name": "claude-opus-4-5-20251101"},
  "workspace": {"current_dir": "...", "project_dir": "..."},
  "version": "2.0.31",
  "output_style": {"name": "default"},
  "cost": {"total_cost_usd": 0.53, "total_duration_ms": 343171, ...},
  "exceeds_200k_tokens": false
}

No context_window field at all.

Expected Behavior

The statusline payload should include context usage data as documented, allowing users to create statuslines like:

[claude-opus-4-5-20251101] Context: 33%

Workaround

Until this is fixed, users can read the transcript file (path is in the payload) and extract usage from the last API response:

"statusLine": {
  "type": "command",
  "command": "bash -c 'input=$(cat); MODEL=$(echo \"$input\" | jq -r \".model.display_name // .model.id\"); TRANSCRIPT=$(echo \"$input\" | jq -r \".transcript_path // empty\"); if [ -n \"$TRANSCRIPT\" ] && [ -f \"$TRANSCRIPT\" ]; then USAGE=$(tail -50 \"$TRANSCRIPT\" | grep -o \"\\\"usage\\\":{[^}]*}\" | tail -1); INPUT=$(echo \"$USAGE\" | grep -oE \"\\\"input_tokens\\\":[0-9]+\" | grep -oE \"[0-9]+\"); CACHE_CREATE=$(echo \"$USAGE\" | grep -oE \"\\\"cache_creation_input_tokens\\\":[0-9]+\" | grep -oE \"[0-9]+\"); CACHE_READ=$(echo \"$USAGE\" | grep -oE \"\\\"cache_read_input_tokens\\\":[0-9]+\" | grep -oE \"[0-9]+\"); TOTAL=$((${INPUT:-0} + ${CACHE_CREATE:-0} + ${CACHE_READ:-0})); PCT=$((TOTAL * 100 / 200000)); else PCT=0; fi; printf \"[%s] Context: %d%%\" \"$MODEL\" \"$PCT\"'"
}

This works but is fragile and shouldn't be necessary.

Request

Please add the documented context_window fields to the statusline payload so users can easily display context percentage.

Environment

  • Claude Code version: 2.0.31
  • OS: macOS Darwin 25.1.0

View original on GitHub ↗

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