cc-token-statusline

A Claude Code status line badge for what a session is actually costing — context window, account quota with reset countdowns, cumulative tokens and cache hit rate.

The badge rendered twice: an everyday session, and one where the context is filling up and the weekly quota is getting tight

Colors move on their own thresholds, so the line changes shape when something needs attention instead of reading the same at 9% and at 82%.

Install

/plugin marketplace add Alfafis/cc-token-statusline
/plugin install cc-token-statusline@cc-token-statusline

Installing the plugin is not enough on its own: Claude Code reads statusLine only from settings.json, and no plugin can register one. The first session after install offers to do the wiring — say yes once and it is done.

Already using another status line? Claude Code allows exactly one command, so yours is wrapped instead of replaced: it runs first with the same payload, and the badge is appended to its output. It gets a short timeout and its failures are swallowed, so a slow or broken one cannot take the bar down. --replace drops it, --uninstall puts it back.

What each segment means

SegmentReadsWhy it earns the space
ctxContext window used against the model's limitThe only value that goes down as well as up. Yellow at 60%, red at 85% — you see the wall before hitting it.
quotaBoth account rate limit windows, 5h and 7dAccount-wide, not per session. Each window carries its own countdown, so a reset is never read against the wrong clock. The 5h one is always shown — it is the window that stops the session you are in; the 7d one appears once it passes 70%.
spent (off by default)Cumulative billed input and output for the sessionConsumption since the start, as opposed to the occupancy ctx measures.
cache (off by default)Share of billed input served from cacheHigher is better. A rate falling through a long session means something large and unstable near the top of the prompt is invalidating the cache each round.
lines (off by default)Lines added and removedThe size of what was actually changed, next to what it cost to change it.

Only the first two are on by default, because the badge is there to say whether you can keep going and only they answer that. spent, cache and lines are on the same footing as cost (reports 0 on subscription plans in some setups), api (time already spent waiting — nothing you do next changes it) and sub (a running total for work that already happened): all six are implemented and off. Name any of them in CC_TOKENS_SEGMENTS and it comes back.

There is a second reason to leave spent, cache and sub off: they are the only segments read from the transcript, so a badge without them never opens it and never writes a session cache. Everything the default set prints comes from the payload Claude Code already hands over.

How the numbers are obtained

Context, quota and edited lines arrive in the status line JSON payload. Cumulative tokens, cache hit rate and subagent spend do not, so the session transcript is parsed — but only when one of those three is asked for, which the default set never does. Two details decide whether that parse is correct and cheap:

Any error prints nothing and exits 0 — a non-zero exit would hide the entire status bar, so a bug here degrades to an empty badge rather than a broken terminal.

Full breakdown

The badge is a glance. For the numbers behind it, /token-report prints fresh input, cache writes, cache reads, output, thinking tokens and subagent totals for the session, then both quota windows and the time left on each.

Configuration

Everything is an environment variable, settable in the env block of settings.json.

VariableDefaultEffect
CC_TOKENS_LANGenLabel language: en or pt. Segment keys never change with it.
CC_TOKENS_SEGMENTSctx,quota,tok,cache,linesWhich segments, in order. Add cost, sub or api to get them back.
CC_TOKENS_WIDTHterminal width − reserveHard cap on badge width. Worth pinning: stdout is a pipe, so terminal size has to be guessed.
CC_TOKENS_RESERVE34Columns left for other badges sharing the line.
CC_TOKENS_COLOR10 disables color. NO_COLOR works too.
CC_TOKENS_ASCIIunset1 forces ASCII glyphs. Applied automatically on consoles that cannot encode the originals.

When the badge does not fit, segments are dropped in a fixed order: api → lines → sub → spent → cache → cost → quota → ctx. Turning a name on does not spare it from that order, which is why the list covers every segment and not just the two defaults. Cache outranks the running total on purpose — a hit rate is actionable, a scoreboard is not.

Footprint