Long sessions die silently. Context fills up, the model quietly starts forgetting — and you don't notice until it loses the thread. So I had Claude Code build its own fuel gauge: model, effort, and two live bars, on one row.
If you run Claude Code all day, you know the moment: an hour deep into a build, the model starts forgetting things it said ten minutes ago. The context window filled up and nothing warned you. The default status line tells you almost nothing — so you fly blind until the AI loses the plot, mid-task, with no fuel light on the dash.
Claude Code hands a small statusline JSON to a script on every refresh — model, effort, context used, session tokens, last prompt. I asked the AI to read that and render a cockpit row: Opus 4.8 [high] [███░░░]13% contxt [██░░░░]13% sess.token. Two ASCII fuel bars. It wrote, tested, and installed the whole thing in one pass.
No magic. Claude Code pipes a tiny JSON object to your script's stdin; whatever the script prints becomes the status line. Read the fields, do the math, draw the bars. Here's the shape of the data the script reads on every redraw — the raw "how it works" layer.
The bars are an estimate, not a fuel-injection readout. context_used_pct tracks the window; the session-token bar is cumulative spend against a cap you set. Treat them as a dashboard light, not a lab instrument — when context crosses ~80%, that's your cue to /compact or start fresh, not a hard cliff.
From a fresh 0% start to the ~80% "time to compact" zone, plus the raw data behind it. Tap any image to enlarge it and read the exact prompt that drew it.




The bars climb as I work. When context crosses the line, I /compact on purpose instead of getting caught out. The AI built its own fuel gauge — and now it tells me when its own tank is running low.
Watch the bars climb during a real session — and the one prompt that built the whole gauge.
The whole status line is one small Node script and a three-line settings block. Copy both below, restart Claude Code, done. No repo, no sign-up.
~/.claude/statusline.js// statusline.js - a Claude Code status line with two fuel bars.
// Output: Opus 4.8 [high] [███░░░░░░░]13% contxt [██░░░░░░░░]13% sess.token
//
// Claude Code pipes a JSON object to this script's stdin on every refresh;
// whatever the script prints becomes the status line. Needs Node 16+.
'use strict';
const fs = require('fs');
let data = {};
try { data = JSON.parse(fs.readFileSync(0, 'utf8').replace(/^\uFEFF/, '')); } catch (_) {}
const get = (o, ...k) => k.reduce((c, key) => (c == null ? c : c[key]), o);
const clamp = (n) => Math.max(0, Math.min(100, Math.round(Number(n) || 0)));
const CYAN = '\x1b[36m', YELLOW = '\x1b[33m', DIM = '\x1b[90m', RESET = '\x1b[0m';
const bar = (pct) => {
const filled = Math.round(pct / 10);
return '[' + CYAN + '█'.repeat(filled) + DIM + '░'.repeat(10 - filled) + RESET + ']';
};
// model name, without the "Claude " prefix
const model = String(get(data, 'model', 'display_name') || 'Claude').replace(/^Claude\s+/i, '');
const effort = get(data, 'effort', 'level');
// bar 1: how full the context window is
const cw = data.context_window || {};
const size = Number(cw.context_window_size) || 200000;
const contxt = clamp(cw.used_percentage != null
? cw.used_percentage
: (Number(cw.total_input_tokens) || 0) / size * 100);
// bar 2: plan usage in the 5-hour window (Pro/Max), else tokens vs window size
const fiveHour = get(data, 'rate_limits', 'five_hour', 'used_percentage');
const sess = clamp(fiveHour != null
? fiveHour
: ((Number(cw.total_input_tokens) || 0) + (Number(cw.total_output_tokens) || 0)) / size * 100);
const parts = [YELLOW + model + RESET];
if (effort) parts.push('[' + effort + ']');
parts.push(bar(contxt) + contxt + '% contxt');
parts.push(bar(sess) + sess + '% sess.token');
console.log(parts.join(' '));
~/.claude/settings.json{
"statusLine": {
"type": "command",
"command": "node ~/.claude/statusline.js"
}
}
3 Restart Claude Code. The bars refresh on every turn. Change the colours or the bar width and make it yours.
Same fuel gauge, same control — but the terminal and a Telegram bot win on every real task. I stopped opening the desktop app. Here's why.