A Claude Code statusline

tokendiet

Your session's context is what you pay for, on every single turn. This puts the number where you'll see it — and tells you when to /clear.

claude code Opus 5 · ~/myproject · main* · ░░░░░░░░░░ 12K/1.0M · $0.18a fresh session — context is cheap here Opus 5 · ~/myproject · main* · █░░░░░░░░░ 104K/1.0M · $1.90turn +18K · $0.21 · 6mevery turn re-sends everything before it Opus 5 · ~/myproject · main* · █░░░░░░░░░ 185K/1.0M · $3.42 · ◐ /clear when this task endsturn +40K · $0.35 · 1.7× vs first turn · 21m150K — still only 18% of the window, already the yellow zone Opus 5 · ~/myproject · main* · ███░░░░░░░ 340K/1.0M · $9.10 · ◐ /clear when this task endsturn +85K · $0.72 · 3.4× vs first turn · 48mthe same question, three and a half times the price Opus 5 · ~/myproject · main* · ██████░░░░ 620K/1.0M · $18.40 · ⚠ /clearturn +160K · $1.40 · 6.7× vs first turn · 1h34m"half full" by the percentage — and every question costs 6.7x Opus 5 · ~/myproject · main* · ░░░░░░░░░░ 6K/1.0M · $0.04/clear — back to paying only for what this task needs

One session, start to finish. Green under 150K tokens, yellow past it, red past 350K.

Install

$ git clone https://github.com/mcancellotti/tokendiet
$ cd tokendiet && python3 install.py

Copies the script into ~/.claude/ and sets the statusLine block in settings.json, leaving the rest of your settings alone — with a backup next to it. On Windows the same installer runs as python install.py. Python 3.8+, no dependencies, MIT.

You are not paying for the answer

I tried to cut my own bill the obvious way: asking for shorter replies. Then I measured my five largest sessions. Output was about a tenth of the spend, and only a quarter of that was prose. I had been optimizing roughly 1.5% of the bill.

66%cache reads — re-sending what the session already holds
24%cache writes
10%output — a quarter of it prose, the rest tool calls

The driver is session length, not verbosity. Every turn re-sends the accumulated context, so a session that has grown to 500K tokens pays for 500K on every turn, whether the answer is three words or three pages. Cost grows quadratically with how long you stay. The lever is knowing when to clear.

Percent of window is the wrong meter

Most context meters show how full the window is. That number is real, but it isn't the one attached to your card. Here is the same 500K session, read both ways.

What the window meter shows
500K 50% full

Reads as plenty of room left. Nothing here suggests you should stop.

What each turn actually costs
200K 1.0×
500K 2.5×

Same session. Every question you ask from here costs two and a half times what it cost at 200K — until you clear.

So the colours key off absolute token counts, not percentages: yellow at 150K, red at 350K. The bar still fills relative to the window, because knowing how much room is left is useful too. It just isn't what determines the bill.

What the turn you just took cost

The bar tells you where the session stands. The second line tells you what it means for the next thing you type — the turn that just finished, set against the first turn of the session.

Opus 5 · ~/myproject · main* · ██████░░░░ 620K/1.0M · $18.40 · ⚠ /clear
turn +160K · $1.40 · 6.7× vs first turn · 1h34m

Nothing there is modelled or predicted. A turn's cost is the difference between two readings of the session total, and the multiplier is that figure measured against the first turn that cost anything. It is the argument on this page reduced to a single number, taken from your own session: the question you are about to ask costs nearly seven times what the same question cost ninety minutes ago.

The multiplier stays hidden until it passes 1.15x — a line that prints 1.0× every turn is a line people stop reading.

It costs nothing to run

A statusline is drawn by your terminal. It never enters the conversation, so watching your spend does not add to it.

The alternative would be a hook injecting a warning into the context on every prompt — paying for that warning in input tokens each turn, out of exactly the budget it exists to protect. And no automation can run /clear for you: it's a harness command, not something a hook or a skill can invoke. Whatever you build, a human makes the call. The job is to put the number in front of that human as cheaply as possible.

Configuration

VariableDefaultEffect
TOKENDIET_WARN150000Tokens at which the bar turns yellow
TOKENDIET_HIGH350000Tokens at which it turns red
TOKENDIET_TURN1Set to 0 to drop the per-turn second line
NO_COLORunsetSet to anything to drop the colour