Skip to content

The quality status line

The quality status line keeps three things in your Claude Code terminal that a single session view never shows together: how full the context window is, how well the context is actually being used right now, and, once there is a figure worth announcing, what Token Optimizer has saved you. You read them at a glance and compact at the right moment instead of guessing.

The live quality bar in the status line, colors shifting as context fills

The status line renders a compact two-row readout below your prompt. The first row shows your model, the effort level, the project directory and branch, a context-fill bar with a used percentage, and the context-quality grade. The second row leads with your savings headline when there is one worth showing, then a resumable-checkpoint mark when one exists, the biggest drag on the score, any active fill or tool-call warnings, the compaction count, the session duration, running agents, and your usage-limit windows.

Claude | med | my-project | (main) | ████████░░ 78% | Quality C 62
Saved $53/30d · 1.2M kept out ↗ | Drag:context fill | compacted 1× | 2h14m | 5 hours 61% ↺2:14p | week 34%

The savings headline uses the shared savings calculation: the last 30 days from $60 with tokens kept out of context when positive, otherwise a tokens-only figure from one million tokens, and nothing below those floors. The display also supports a $20 weekly floor, but the current calculation does not supply a weekly figure. It is read from the status-bar cache that measure.py status-bar writes, so the status line never spawns Python to get it, and in terminals with hyperlink support it is a clickable link to the dashboard’s Savings page. The usage-limit fragments (the 5-hour window with its reset time, and the week) appear on Pro/Max accounts once the first API response of the session reports them, colored by pressure.

When the terminal reports its width (Claude Code v2.1.153+), each row’s segments reflow onto as many physical lines as the width allows instead of being clipped. TOKEN_OPTIMIZER_STATUS_BAR_SIZE=slim collapses the whole thing to a single line: the first row, with the savings headline appended, plus the prompt cache when it is cold or has under 5 minutes left.

The fill bar is color-banded so a glance tells you the state: green under 50%, yellow to 70%, orange to 80%, and red above 80%. The quality grade runs from S (90+) down to F, and carries the same value-color so a low grade reads as a warning. A ~ prefix on the grade means the cached score is older than five minutes and may not be live.

The grade is the same context-quality score documented in quality scoring. The status line is how you watch it move without running a command.

Paths shown as ~/.claude/token-optimizer/ are legacy script-install paths. Plugin installs resolve state under their plugin-data identity; use the runtime’s reported data directory rather than creating a second legacy copy.

The fill percentage comes from the data Claude Code hands the status line on every render. The quality grade comes from a small cache file that Token Optimizer’s hooks keep updated.

A UserPromptSubmit hook recomputes the quality score on a roughly two-minute throttle and writes it to ~/.claude/token-optimizer/quality-cache-<session_id>.json. The status line reads that file on each render. Because the cache is refreshed on a throttle rather than every keystroke, the status line applies a five-minute staleness guard: past that age it marks the grade with ~ rather than showing a frozen number as if it were live.

setup-quality-bar installs the status line into ~/.claude/settings.json and wires the quality-cache hook that feeds it.

  1. Install the status line and its hook:

    Terminal window
    cd ~/.claude/skills/token-optimizer/scripts
    python3 measure.py setup-quality-bar
  2. Preview the change first, or check the current state, without writing:

    Terminal window
    python3 measure.py setup-quality-bar --dry-run
    python3 measure.py setup-quality-bar --status

To remove it:

Terminal window
cd ~/.claude/skills/token-optimizer/scripts
python3 measure.py setup-quality-bar --uninstall

Uninstalling removes the status line and records a sticky opt-out (quality_bar_disabled in config.json) so it does not reappear on the next session start. Run setup-quality-bar again to clear the opt-out and reinstall.

On for plugin and marketplace users. The SessionStart ensure-health hook auto-installs the status line through setup-quality-bar when your statusLine slot is empty, and respects the quality_bar_disabled opt-out. Skill-only users install it once with the command above.

Platform availability: the terminal status line is a Claude Code surface. Codex has its own status-line command (codex-status-line). OpenClaw has no terminal status-line surface. See the capability matrix.

Claude Code’s /statusline command rewrites the statusLine setting, which replaces the quality bar with whatever it generates. How Token Optimizer responds depends on how you installed it.

For skill-only installs, the status line is restored: the next SessionStart ensure-health detects that the slot no longer holds the quality bar and reinstalls it, unless you have set the opt-out.

For plugin installs, there is no auto-restore after /statusline clobbers the bar. Claude Code exposes no signal that distinguishes an accidental clobber from a status line you chose on purpose, so the plugin does not second-guess your choice. This is a deliberate, accepted trade-off. To get the quality bar back after /statusline replaces it, run setup-quality-bar again.

Reading the cache from a custom status line

Section titled “Reading the cache from a custom status line”

If you maintain your own status line and want the quality grade in it, read the cache file directly. Token Optimizer writes the per-session score to:

~/.claude/token-optimizer/quality-cache-<session_id>.json

The file holds the score under resource_health (falling back to score), a letter grade under resource_health_grade (falling back to grade), and a session-efficiency score under session_efficiency. Apply your own staleness check against the file’s timestamp; the bundled status line treats a score older than five minutes as stale. The quality-cache hook keeps the file current as long as Token Optimizer is installed, so a custom status line gets the same live grade without running any Token Optimizer command itself.

Automatically. The fill bar updates on every status-line render. The quality grade updates whenever the quality-cache hook runs, which is on UserPromptSubmit (throttled to about two minutes) and after tool use, with a force-refresh on SessionStart and after compaction.

SettingDefaultNotes
Layouttwo rowsRow 1: model, effort, project, branch, fill + quality grade. Row 2: savings headline, resumable mark, drag, warnings, compacts, duration, agents, prompt cache expiry, limits
Fill color bandsunder 50 green, under 70 yellow, under 80 orange, 80+ redOn the used percentage
Quality gradesS 90+, A 80+, B 70+, C 55+, D 40+, F belowSame score as quality scoring
Staleness mark~ after 5 minutesCache older than the guard window
Savings headline floors$60 over 30 days, else 1M tokensThe $20 weekly floor is implemented but has no weekly input yet
Narrow terminalsReflow to fitWhen the host exports COLUMNS; TOKEN_OPTIMIZER_STATUS_BAR_SIZE=slim forces one line
Quality-cache refresh~2-minute throttleOn UserPromptSubmit and PostToolUse
Auto-installon (plugin)When statusLine slot is empty
Opt-outquality_bar_disabledSet by --uninstall, sticky

The terminal status line above has a sibling for the Claude desktop app. Token Optimizer draws a status bar above your prompt: one sentence about the most urgent thing, with at most one button, then five marks (quality grade, context fill, cache countdown, 5-hour limit, weekly limit) that open a card on hover. The arrow beside Clawd unfolds branch, session time, tool calls, compactions, and the last checkpoint. The green savings chip shows what you have saved since install, when there is a figure to show and nothing on the bar needs your attention. Press it, or Dashboard ↗ after the marks, to open the dashboard in your browser. Clawd acts out what the session is doing, from thinking and typing to compacting, a cold cache, or napping.

Buttons: Clean up compacts with Token Optimizer’s guidance. Start fresh asks for a second click, then saves a checkpoint, clears, and hands the checkpoint to your first message. Keep warm is a manual cache refresh, covered in Keep-Warm.

The cache countdown prefers Claude Code’s native prompt_cache object (v2.1.251+), bridged by the terminal status line: TTL, expiry, and warm/cold state describe the main conversation, not subagents. When that bridge is unavailable, it falls back to a transcript-based estimate: 1 hour on Claude plans or 5 minutes on the API. Native and estimated sources are distinguished; no countdown is shown without an anchor. Use the -/+ size control for a remembered one-line/full choice, or TOKEN_OPTIMIZER_STATUS_BAR_SIZE=slim for the initial desktop and terminal size. Hide the bar with TOKEN_OPTIMIZER_STATUS_BAR=0, or keep Clawd still with TOKEN_OPTIMIZER_STATUS_BAR_ANIMATE=0, in your settings env. Install steps and requirements are in Claude desktop app.

The 30-day savings figure is counted once for the whole machine, not once per session. Every open session reads the same cached result, and one background refresh at a time updates it. Only the “saved in this session” figure is looked up per session, and it is reused for five minutes.

  • After 60 seconds the cached figure counts as stale, so the next poll starts one background refresh. The refresh has 90 seconds to finish.
  • The last good number stays on screen while a refresh runs and when one fails. A failed refresh never replaces a number with an error. After two failed refreshes in a row, the unfolded row adds a note such as “Last updated 3h 5m ago. Will try again later.” A single failed refresh, or the normal 60-second cycle, shows no note.
  • Failed refreshes back off. The wait before the next try starts at one minute and doubles with each failure in a row, up to ten minutes. A success resets it.
  • The refresh skips work the band never shows. The cache-waste scan behind the dashboard’s cache report does not run during a status-bar refresh, so the band’s number no longer depends on that scan finishing in time. The dashboard still runs it.
  • “Still counting savings” shows only before the first number exists. A new session on a machine that already has a number shows it at once. If Token Optimizer has recorded nothing yet, the band says so instead of “still counting”.
  • After an upgrade, the first refresh starts from the newest figure the old per-session caches held, marked stale, so the band does not start blank.
  • If the plugin cannot be found, is too old, or Python is missing, the band drops the number and says why. It does not keep an old figure behind a permanent problem.
  • The green savings chip on the title row works again. The band was looking for the headline in the wrong place in the data, so the chip never appeared. It shows only on a calm line (good tone, no button) and only when the headline has a number worth showing.

Terminal status line: none. It only displays, and installing it only writes the statusLine setting (and only when the slot is empty). A missing or stale cache shows -- or a ~-marked grade, never a wrong action.

Desktop status bar: low. Its buttons act only when you press them, and Start fresh asks for a second click first. Nothing runs on its own.

The status line is installed and removed by the setup-quality-bar command and the quality_bar_disabled config key, both defined in the configuration reference. Three environment variables shape it directly: TOKEN_OPTIMIZER_STATUS_BAR_SIZE=slim forces the single-line layout described above, TOKEN_OPTIMIZER_STATUS_BAR_SAVINGS=0 hides the savings headline in both layouts, and TOKEN_OPTIMIZER_STATUS_CACHE=0 hides the prompt cache expiry. The expiry shows minutes left only when your statusLine sets a refreshInterval of 60 or less; otherwise it shows the clock time the cache expires, because the line does not redraw while you are idle.

Claude Code CLI and VS Code. Codex uses codex-status-line. OpenClaw has no terminal status-line surface. See the capability matrix.