Measure
Claude Code status line generator
A status line that shows what the session costs while you work: context fill, burn rate, how long the prompt cache stays warm, and what the next request re-caches if it goes cold.
Pick segments and thresholds, check the preview against real-shaped input, then download one Node script. It runs the same renderer as this preview. Cache-write prices verified 2026-11-20 against Anthropic’s pricing page.
No rate_limits: plan usage hides. Preview clock is fixed and no git branch is looked up; the script uses the real time and adds your branch to the folder segment.
89 of 160 columns. Hidden, no data: 5h / 7d plan usage.
Segments
Order is left to right. When the terminal is too narrow, the lowest priority drops first.
- Model + effortmodel.display_name and effort.level
- Context %context_window.used_percentage, colored by threshold
- Session cost + burn ratecost.total_cost_usd and $/hour over cost.total_duration_ms
- Cache warm/coldprompt_cache.warm and a countdown to prompt_cache.expires_at
- Cost if the cache goes coldEstimate: prompt_cache.recache_tokens_if_cold × the cache-write price for model.id
- Last cache miss + hit ratioprompt_cache.last_miss_cause.causes and prompt_cache.hit_ratio
- 5h / 7d plan usagerate_limits.five_hour and seven_day with reset countdowns
- Folder + git branchworkspace.current_dir and the current branch (cached per session)
Thresholds
Colors
Preview input
Install
- Save the script as
~/.claude/statusline.mjs(on Windows,C:/Users/you/.claude/statusline.mjs). It needs Node 18 or later and nothing else. - Add this to
~/.claude/settings.json. Keep forward slashes: on Windows, Claude Code runs the command through Git Bash, which treats backslashes as escapes.{ "statusLine": { "type": "command", "command": "node ~/.claude/statusline.mjs", "padding": 0 } } - Test it outside Claude Code:
echo '{"model":{"display_name":"Opus"}}' | node ~/.claude/statusline.mjs
No install at all: paste the /statusline prompt into Claude Code and it writes an equivalent script for you. That copy is Claude’s, not this one, so its output can differ from the preview.
Troubleshooting
- The status line is blank
- Claude Code only runs it after you accept the workspace trust dialog for the folder. Run
claude --debugto see “Status line command skipped: workspace trust not accepted” or the script’s stderr. - Permission denied
- The snippet runs
node ~/.claude/statusline.mjs, which needs no execute bit. If you pointcommandat the file directly, runchmod +x ~/.claude/statusline.mjsfirst. - Windows
- Claude Code runs the command through Git Bash when it is installed, otherwise PowerShell. Use forward slashes (
C:/Users/you/.claude/statusline.mjs) or~: backslashes are eaten as escapes and the command fails without an error. - It disappeared on a work machine
- If your organization sets
allowManagedHooksOnlyin managed settings, only a status line from those managed settings runs. AdisableAllHooks: trueoutside managed settings has the same effect. Ask your administrator.
Reference: the Claude Code status line docs.
FAQ
- Where do the numbers come from?
- Claude Code sends a JSON object to your status line script on every update: model, context window, session cost, prompt-cache state and, for Pro and Max plans, rate limits. The script formats those fields and makes no network calls.
- How is the cost-if-cold estimate computed?
- prompt_cache.recache_tokens_if_cold times the cache-write price for your model: the 5-minute or 1-hour rate, depending on prompt_cache.ttl, from Anthropic's pricing page. It is an estimate at list price; a model the table does not know hides the segment.
- Why is a segment missing?
- Missing data hides a segment instead of printing null. rate_limits only exists for Pro, Max and Ultra plans or behind a gateway with a spend limit, prompt_cache appears after the first response, and context percentages can be null early in a session.
Want a general-purpose, themeable status line instead? See ccstatusline and claude-powerline (both MIT).
Next step
The status line shows the cost. The audit shrinks it.
A cold cache re-writes everything that loads on every request. The audit finds the part of that always-on context you did not need.