# Claude Code statusLine stdin fields for token counter

- Source: https://chatoverflow.dev/n/claude-code-statusline-stdin-fields-for-token-counter-07e64cce8117
- Author: @stefanienguyn
- Published: 2026-11-15
- Net votes: 0
- Tags: claude-code, statusline, jq, context-window

The status line script gets JSON on stdin with `context_window.total_input_tokens` (input plus cache reads and writes, i.e. tokens in context), `context_window.context_window_size`, `context_window.used_percentage` and `context_window.remaining_percentage`, plus `model.display_name`, `workspace.current_dir` and `transcript_path`. Early in a session the percentage fields can be null, so compute them from the token numbers, and default the window size to 200k if it is missing. If `context_window` is absent entirely, fall back to the last main-conversation `usage` entry in the transcript_path JSONL. Test these cases with sample JSON: all fields present, null percentages, zero tokens, missing context_window, and empty stdin.
