Hinaser/Claude-Code-Statusline

โ˜… 0Forks 0ShellGitHub โ†—Compare

README

Claude Code Status Line

A custom status line for Claude Code that shows useful session info at a glance.

Requires a Nerd Font for some icons.

Screenshot

Opus5(high) ๐Ÿ“Š 72%(56.0k/200k) ๐Ÿ’ฒ2.18(+0.12) ๓ฐชฐ 99%(+1.2k) ๐Ÿ”ฅ10:42โ†’11:42(~$0.85) โณ 5h/7d: 42%/18%
๐Ÿ“‚ current_dir ๎‚  main*โ†‘2 ๐Ÿ“ +120/-35 ๐Ÿง  1.2k/3.4k ๓ฐ‘– 7 ๓ฐ”› 1m10s

What it shows

Icon Metric Description
Model Model name, version and reasoning effort (e.g. Opus5(high), Opus4.6(high))
๐Ÿ“Š Context Remaining %, used/total tokens. Red below 20%
๐Ÿ’ฒ Cost Total session cost in USD, and how much it rose at the last change (+0.12). The previous total is kept per session in a small file in the OS temp directory, since the status line payload only carries the running total
๓ฐชฐ Cache Prompt cache hit ratio of the last request, and tokens written to the cache by it (+12.7k)
๐Ÿ”ฅ/โ„๏ธ Cache TTL Time of the last API response โ†’ when its prompt cache expires. ๐Ÿ”ฅ while still hot, โ„๏ธ (red) once expired. (5m) is appended when the last request only wrote to the 5-minute cache. (~$0.85) is the estimated cost of the first request after expiry, which has to rewrite the whole cache
๐Ÿ“‚ Folder Current working directory name (second line)
๎‚  Branch Current git branch. * when there are uncommitted changes, โ†‘2/โ†“1 for commits ahead of/behind upstream
๐Ÿ“ Lines Lines added/removed in this session (+120/-35), shown once non-zero (second line)
๐Ÿง  Last turn How hard the model worked on the last prompt: thinking/output tokens, ๓ฐ‘– API steps (tool round-trips) and ๓ฐ”› wall time. Compare turns across effort levels. Thinking tokens are left out for models that don't report them (second line)
โณ Plan limits Usage of the 5-hour and weekly plan limits. Each value is red at 80% or more. Shown only when Claude Code reports them (subscription plans)

Setup

  1. Copy statusline-command.sh to ~/.claude/:

    cp statusline-command.sh ~/.claude/statusline-command.sh
    chmod +x ~/.claude/statusline-command.sh
  2. Add to ~/.claude/settings.json:

    {
      "statusLine": {
        "type": "command",
        "command": "bash ~/.claude/statusline-command.sh"
      }
    }
  3. Restart Claude Code.

Requirements

  • Node.js (used to parse the JSON data from stdin)
  • Nerd Font in your terminal for and ๓ฐชฐ icons
  • Git (for branch detection)

How the cache TTL label works

The status line only re-renders when the conversation updates, so an elapsed-time counter would freeze while you are idle. Instead the label shows absolute clock times: the timestamp of the last assistant entry in the session transcript (transcript_path from the status line payload) and that time plus the cache TTL. The TTL is taken from the last response's usage.cache_creation: 1 hour normally, 5 minutes if the request only wrote to the 5-minute cache. Reading it at a glance tells you whether resuming now will hit the cache (cheap) or rewrite the whole context (expensive), and when to run /compact before stepping away.

How the resume cost is estimated

Claude Code reports prompt_cache.recache_tokens_if_cold (how many tokens the next request would have to write to the cache if it has expired) and prompt_cache.ttl. The estimate is those tokens times the model's cache-write price: the input price ร—2 for the 1-hour TTL, ร—1.25 for the 5-minute TTL. Input prices are hard-coded per model family in the script (Fable $10, Opus 5.5 $4, Opus 4.5โ€“5 $5, Sonnet 5 $2, Sonnet 4.x $3, Haiku 4.5 $1 per million tokens); unknown models show no estimate. It is shown while the cache is still hot too, since the status line doesn't re-render while you are idle: read it as "what it costs to come back after the expiry time".

How the last-turn effort is measured

The transcript is read backwards to the start of the last turn: a prompt you typed, or a background-task notification that woke the model up (tool results, interrupts, slash commands and compact summaries don't count). Every API response since then adds its usage.output_tokens and usage.output_tokens_details.thinking_tokens; a response is written as several entries sharing one message.id, so each id is counted once, and the number of ids is the step count. Wall time is the turn_duration Claude Code writes when the turn ends, or prompt โ†’ latest entry while it is still running. The thinking text itself isn't stored, so token counts are the only measure of depth.

License

MIT

Contributors

Hinaser

Issues