| |

Claude Code Statusline: The 3-Number Setup I’d Give Anyone on a Subscription (Context, Cache Countdown, 5-Hour Reset)

claude code statusline

A Claude Code statusline is the one-line bar under your prompt. It runs a shell script you choose, passes it a JSON snapshot of your session, and shows whatever the script prints. Most setups use it as a dashboard: model, folder, git branch, a cost estimate, a context bar. That’s fine. But if you’re on a Pro, Max or Ultra subscription, three numbers in that JSON matter more than everything else: how full your context is, how long until your prompt cache goes cold, and when your 5-hour limit resets.

This guide sets up a Claude Code statusline in about a minute, then gives you a copy-paste script (bash and Python) built around those three numbers. I tested both versions in my container on 26 November 2026 against four test inputs, and one of those tests caught a jq bug that would have quietly shown the wrong answer. I’ll show you the bug too. Every docs fact below was re-read on code.claude.com the same day.

One honest note first. I run 12 daily jobs and 10 weekly ones as unattended Claude Code agents on a server, and none of them has a status line. There’s no terminal for anyone to look at. So the last part of this post covers what I watch instead when nobody is at the keyboard.

How to Set Up a Claude Code Statusline in 60 Seconds

claude code statusline

There are two ways to set it up. Both end with the same thing: a statusLine entry in your settings file that points at a command.

Option 1: let Claude write it with /statusline

Type /statusline followed by what you want, in plain English:

/statusline show model name and context percentage with a progress bar

Claude Code writes a script into ~/.claude/ and updates your settings for you. Approve the file edits when it asks. This is the fastest route, and it’s a good way to get a working base you can then edit by hand.

Option 2: write the settings yourself

Add this to ~/.claude/settings.json (or a project’s settings file):

{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh",
    "padding": 0
  }
}

Then create the script, run chmod +x ~/.claude/statusline.sh, and save. Claude Code reloads settings by itself and runs the script straight away. There’s nothing to restart.

The settings object takes a few optional fields worth knowing:

  • padding: extra horizontal spacing in characters. Defaults to 0.
  • refreshInterval: re-runs your command every N seconds (minimum 1) on top of the normal event-driven updates. You’ll want this for the countdowns below.
  • hideVimModeIndicator: hides the built-in -- INSERT -- text if your script shows vim mode itself.

How to turn it off

Run /statusline delete (or “clear”, or “remove it”), or delete the statusLine field from settings.json. The status line runs locally and, according to the docs, doesn’t use any API tokens, so leaving it on costs you nothing from your plan.

If you want the full list of slash commands around this one, I keep a Claude Code cheat sheet that I re-check against the docs.

What Data Your Claude Code Statusline Script Receives

JSON fields a Claude Code statusline script receives on stdin

Your script gets one JSON object on stdin every time it runs. Whatever it prints to stdout becomes the line. The docs list over 40 fields. Here are the ones that actually change what you do:

FieldWhat it tells youCatch
context_window.used_percentageHow full the context window isInput tokens only. Can be null early in a session
prompt_cache.warmWhether the cached prefix is still liveMain conversation only. Subagents aren’t counted. Needs v2.1.251+
prompt_cache.expires_atWhen the cache goes cold (epoch seconds)null if the last response had no cache tokens
prompt_cache.ttlCache lifetime: "5m" or "1h"Tells you which billing bucket you’re in (more below)
prompt_cache.hit_ratioShare of input read from cache, 0 to 1A session average, not the last turn
rate_limits.five_hour.used_percentage / .resets_at5-hour window use and reset timePro, Max and Ultra only, and only after the first response
rate_limits.seven_day.*The weekly window, same shapeCan be absent on its own
cost.total_cost_usdEstimated session cost at list priceNot your bill on a subscription
model.display_name, effort.levelWhat’s running and how hard it thinkseffort is absent on models without effort levels

Three things in that table trip people up.

Missing is not the same as zero. rate_limits only shows up for claude.ai subscribers (or behind a gateway with a spend limit), and only after the first API response. Claude Code also drops a window once its resets_at time passes. So your script has to treat “absent” as a normal state, not an error.

The cost number isn’t what you pay. cost.total_cost_usd is worked out on your machine at list price. On Pro or Max you pay a flat fee, so a status line that shows “$4.12” is showing you a what-if. It’s useful for comparing sessions, but not for budgeting. I covered what the flat fee actually buys in my breakdown of the Claude Code Pro price.

The context number can disagree with /context. The status line uses the counts from the last API response. /context adds an estimate for messages since then, so it can read higher until the next reply lands. The docs say to trust used_percentage for the simplest accurate reading.

The 3-Number Claude Code Statusline: Copy-Paste Script

Three readings in a Claude Code statusline: context, cache countdown and rate-limit reset

Here’s the line this script prints:

ctx 42% | cache 37m/1h | 5h 24% resets 18:22

Read it left to right: the context window is 42% full; the prompt cache is warm, has 37 minutes left, and is on the 1-hour lifetime; you’ve used 24% of your 5-hour window, and it resets at 18:22 local time.

The bash version (needs jq)

Save as ~/.claude/statusline.sh:

#!/bin/bash
# 3-number status line: context %, cache countdown, 5h reset
# One jq call. Note: tostring, not "// empty", so warm=false survives.
IFS=$'\t' read -r CTX WARM EXP TTL FIVE RESET < <(jq -r '[
  (.context_window.used_percentage // 0 | floor),
  (.prompt_cache.warm | tostring),
  (.prompt_cache.expires_at // "" | tostring),
  (.prompt_cache.ttl // ""),
  (.rate_limits.five_hour.used_percentage // "" | tostring),
  (.rate_limits.five_hour.resets_at // "" | tostring)
] | @tsv')
now=$(date +%s)

if [ "$WARM" = "true" ] && [ -n "$EXP" ]; then
  left=$(( (EXP - now) / 60 )); [ "$left" -lt 0 ] && left=0
  CACHE="cache ${left}m${TTL:+/$TTL}"
elif [ "$WARM" = "false" ]; then
  CACHE="cache cold"
else
  CACHE="cache --"
fi

if [ -n "$FIVE" ] && [ -n "$RESET" ]; then
  T=$(date -d "@$RESET" +%H:%M 2>/dev/null || date -r "$RESET" +%H:%M)
  LIMIT="5h $(printf '%.0f' "$FIVE")% resets $T"
else
  LIMIT="5h --"
fi

echo "ctx ${CTX}% | ${CACHE} | ${LIMIT}"

The date -d ... || date -r ... line handles both Linux (GNU date) and macOS (BSD date).

The Python version (no jq needed)

Save as ~/.claude/statusline.py and point command at it:

#!/usr/bin/env python3
# 3-number status line: context %, cache countdown, 5h reset
import json, sys, time
from datetime import datetime

d = json.load(sys.stdin)
now = time.time()

ctx = int((d.get("context_window") or {}).get("used_percentage") or 0)

pc = d.get("prompt_cache") or {}
if pc.get("warm") and pc.get("expires_at"):
    left = max(0, int((pc["expires_at"] - now) // 60))
    ttl = f"/{pc['ttl']}" if pc.get("ttl") else ""
    cache = f"cache {left}m{ttl}"
elif pc.get("warm") is False:
    cache = "cache cold"
else:
    cache = "cache --"

five = (d.get("rate_limits") or {}).get("five_hour") or {}
if five.get("used_percentage") is not None and five.get("resets_at"):
    reset = datetime.fromtimestamp(five["resets_at"]).strftime("%H:%M")
    limit = f"5h {five['used_percentage']:.0f}% resets {reset}"
else:
    limit = "5h --"

print(f"ctx {ctx}% | {cache} | {limit}")

What happened when I tested it

I ran both scripts in my container against four fake inputs, as the docs’ tips section suggests: a warm cache with limits, a cold cache, a first-turn snapshot where used_percentage is still null, and an empty {}. These are test inputs, not a live session. A cron container has no interactive terminal to run one in, so I’m not going to show you a screenshot I didn’t take.

InputOutput (both versions)
Warm cache, 1h TTL, limits presentctx 42% | cache 37m/1h | 5h 24% resets 18:22
Cache gone cold, no limits yetctx 71% | cache cold | 5h --
First turn, context still nullctx 0% | cache -- | 5h --
Empty objectctx 0% | cache -- | 5h --

The bug my first draft had. My first bash version read the cache state with jq -r '.prompt_cache.warm // empty', the same “// fallback” pattern the docs use for other fields. In jq, // treats false the same as missing. So when the cache went cold, jq printed nothing, and my line showed cache -- (“no data”) instead of cache cold. That’s the wrong answer at the exact moment you need the right one. The Python version got it right from the start. The fix is | tostring, which keeps false as the string “false”. If any field you read can be false, don’t use // on it.

Speed. The first draft called jq four separate times. Twenty runs took 1.27 seconds, or about 64 ms each. The single-jq version above took 0.42 seconds for twenty (about 21 ms each), and Python took about 26 ms. None of these is slow enough to notice. But the docs warn that a slow script blocks updates, and if an update fires while your script is still running, Claude Code cancels it. One jq call instead of six is a habit worth keeping.

Lead Magnet AI Playbook, the operator's AI automation playbook

Get the AI Playbook

The playbook behind my agent fleet: the result line every run must write, the nightly check that reads it, and the setups that stop silent failures. Free, and you can leave whenever you like.

Lead Magnet - AI Playbook

Reading It Right: Warm vs Cold Cache, 1h vs 5m, and the Reset Clock

Warm and cold prompt cache in a Claude Code statusline

Numbers only help if you know what to do when they change. Here’s how I’d read each one.

The cache countdown: when to type, and when to wrap up

Claude Code caches the start of your conversation (system prompt, tools, project context, history) on Anthropic’s side. Each request that hits the cache resets its timer. When the timer runs out, the next request has to re-process the whole thing as fresh input. That’s slower, and on a subscription it eats more of your limit. The recache_tokens_if_cold field tells you roughly how many tokens that first request back will have to re-cache.

So the countdown answers a practical question: if I go to lunch now, will I pay to rebuild this session when I come back? If it says cache 3m and you’re about to step away, send the next prompt first, or accept that the first turn back will be slower and cost more.

The /1h vs /5m suffix: which billing bucket you’re in

This is the part I haven’t seen in any of the hand-written status line tutorials I read. According to the prompt caching docs, on a Claude subscription within your plan’s included usage, Claude Code asks for a one-hour cache lifetime for your main conversation. Once you go over your plan limit and start drawing on usage credits, it drops the main conversation to the five-minute lifetime, because 5-minute cache writes cost less. (You can override this with the promptCacheTtl setting or the CLAUDE_CODE_PROMPT_CACHE_TTL variable.)

That means the suffix tells you something useful. If your line has said /1h all morning and suddenly says /5m, and you haven’t set a TTL yourself, you have most likely moved from plan usage onto paid credits. With the 5-minute lifetime, a coffee break is enough to go cold.

One more note. Subagents and workflows use the five-minute bucket by default, and prompt_cache doesn’t count them at all. A warm main cache doesn’t mean your background helpers are warm.

Jon Jones

⚡ GET THE AI EDGE

Weekly AI tips that actually save you time and money. No fluff, no hype — just what works.

Newsletter Signup - Blog CTA

The 5-hour reset time: plan around it

Pro and Max have a rolling five-hour window and a weekly cap. A percentage on its own makes you nervous. A percentage with a reset time lets you plan. “5h 88% resets 14:10” at 13:50 means: finish the small task, and start the big refactor after 14:10. I go through the three walls (5-hour, weekly, parallel sessions) in the Pro price post, and the /usage screen that shows the full picture in Claude Code usage, explained.

If you want the weekly number too, add seven_day the same way. I left it off the line on purpose. The weekly cap changes slowly, so it belongs in /usage, not in front of you all day.

Why the countdown needs refreshInterval

Without refreshInterval, the line only redraws on events, so a “37m” can sit there unchanged while you read code for twenty minutes. Add "refreshInterval": 30 to the statusLine block and the countdown stays honest. The docs also say the line re-runs by itself when the cache reaches its expires_at and when a rate-limit window reaches its resets_at, so the switch to “cold” will show up even without it. The minutes in between won’t.

When the Claude Code Statusline Updates (and Why Yours Looks Frozen or Blank)

Claude Code statusline update triggers and debounce

Your script runs once when a session starts (including when you resume one), and then again when:

  1. a new assistant message arrives
  2. /compact finishes
  3. the permission mode changes
  4. vim mode toggles
  5. you change the command in settings
  6. a refreshInterval timer elapses, if you set one
  7. a rate-limit window in the last data reaches its resets_at
  8. a warm prompt cache in the last data reaches its expires_at

Updates are debounced at 300 ms, so a burst of changes runs your script once. A newer update cancels a script that’s still running.

“My status line is blank”

Work through these in order. They’re all from the docs’ troubleshooting section, and the first three cover most cases:

  • Workspace trust. Because statusLine runs a shell command, it follows the same trust rule as hooks. Until you accept the trust dialog for that folder, the line stays blank. claude --debug logs Status line command skipped: workspace trust not accepted.
  • Non-zero exit or no output. Claude Code only shows output after the script exits with code 0. A script that errors on a missing field goes blank. This is why every field above has a fallback.
  • Not executable, or printing to stderr. chmod +x, and make sure you echo to stdout.
  • disableAllHooks: true outside managed settings turns off your status line too, unless managed settings define one.
  • allowManagedHooksOnly set by your organisation hides your custom line with no warning. Ask your admin.
  • Windows with Git Bash: use forward slashes in the command path.

claude --debug logs your script’s stderr on every run and its exit code on the first one. That’s the fastest way to see why it’s blank.

“My status line shows — or 0%”

Fields are often null before the first API response. That’s what the first-turn row in my test table shows. Send one message and it fills in. If 5h -- never goes away, you’re probably on an API key or usage credits rather than a subscription window, and rate_limits won’t appear.

“It looks frozen”

It isn’t. Nothing has triggered a re-run. Either set refreshInterval, or remember that it waits for the next reply. Also note that notifications (MCP errors, auto-update notices, the context-low warning) share the same row outside fullscreen mode, and the line hides during permission prompts and the help menu.

If you’re already writing hooks, the trust and disableAllHooks rules will feel familiar. My Claude Code hooks guide covers the same settings layer.

Prebuilt Options: ccstatusline, statusline.sh and Friends

Prebuilt Claude Code statusline tools compared with a hand-written script

You don’t have to write any of this. The docs themselves point to two community projects, and there’s a visual builder too:

ToolWhat it isPick it when
ccstatuslineConfigurable widgets with a terminal UI to set them up (npx -y ccstatusline@latest)You want a lot on the line, themes, Powerline style, and you don’t want to maintain a script
statusline.shA drag-and-drop web builder with templates and a one-line installYou think visually and want a nice-looking line quickly
starship-claudeA community config built around the Starship shell prompt (linked from the docs)You already use Starship in your shell
The 25 lines aboveThree numbers, no dependencies beyond jq or PythonYou want to know exactly what runs on every reply

To be fair about it: ccstatusline already ships a Cache Timer widget (a countdown like 4m 52s) and reset-timer widgets for the 5-hour and weekly windows. If you go that way, you get my three numbers and a lot more. Two things I’d do if I used it:

  • Pin the version. The project’s own README measured bunx -y ccstatusline@latest at a 633 ms median against about 202 ms for a pinned version, because @latest checks the registry every run. A status line runs on every reply, so pin it.
  • Read what you install. A status line command runs on your machine on every update, with your user’s permissions. That’s the same trust question as any hook or plugin. Skim it before you adopt it.

My rule of thumb: use a prebuilt tool if you want more than four things on the line. Write your own if you want three, and want to be able to read the whole script in thirty seconds.

No Status Line When Nobody’s Watching: What My Cron Fleet Uses Instead

Unattended Claude Code agents with no statusline, monitored through written run logs

Here’s the part none of the tutorials I read cover, because they’re about one person at one terminal.

The status line is part of the interactive terminal UI. My agents don’t use that UI. They start on a schedule, run claude -p with a skill file, and exit. There’s no bottom bar to draw on, and no one looking at it. I checked the container today: ~/.claude/settings.json has two keys (the model and a permission-prompt setting) and no statusLine. The CLI is 2.1.292. I couldn’t find a line in the docs that says what happens to a statusLine command in -p mode, so I won’t guess. In my setup the question doesn’t arise.

The three numbers still matter when nobody is watching. They just need a different home:

Status line numberUnattended equivalent in my fleet
Context %Each skill is one bounded job with a hard timeout (blog-writer gets 5,400 seconds), so no session lives long enough to fill up
Cache countdownNot watched. Each run is a fresh session with its own skill file, so there’s no long-running conversation to keep warm
5-hour resetThe schedule itself. Jobs run one at a time at fixed slots, so the fleet’s usage looks much the same every day
“Is it working?”A SKILL_RESULT: success | skip | fail line at the end of every run, plus a nightly watchdog job that reads them

The last row is the one that matters. In the eight days from 18 to 25 November, the fleet logged 106 runs: 104 ended success and 2 ended fail (the newsletter writer on 20 November and the Sendy sync on 22 November). Both of those failures exited with code 0. If I’d only watched exit codes, the way a status line only shows what its script prints, I’d have seen 106 green runs. The written result line is what caught them. Both trace back to the same broken mailing-list ID, which is still on my list to fix.

That’s the lesson I’d carry back to an interactive status line, too: show the thing that tells you what to do next, not just the thing that’s easy to show. A cost figure is easy to show. A cache that’s about to go cold tells you what to do.

If you’re trying to get from one person at a terminal to agents that run on a schedule, and you’d like a second pair of eyes on how you’ll know they’re working, you can book an automation strategy session with me. For the scheduling side, my post on the Claude Code loop covers how recurring runs are set up, and Claude Code memory covers what each run loads when it starts.

Claude Code Statusline FAQ

Claude Code statusline frequently asked questions

Does the Claude Code statusline cost tokens?

No. The docs say it runs locally and doesn’t consume API tokens. Your script reads data Claude Code already has.

Why does my statusline show nothing?

Most often: you haven’t accepted workspace trust for that folder, the script exited with a non-zero code, or it isn’t executable. Run claude --debug to see its stderr and exit code.

Why doesn’t the 5-hour limit show up?

rate_limits only appears for Pro, Max and Ultra subscribers (or behind a gateway with a spend limit), and only after the first API response in the session. On an API key it won’t appear at all.

Can I show two lines?

Yes. Each echo or print becomes its own row. ANSI colors and OSC 8 clickable links also work, but the docs warn that multi-line output with escape codes is more likely to glitch.

How do I fit it to my terminal width?

Claude Code passes the width in the COLUMNS variable and the height in LINES. Don’t call stty size, which can fail inside the status line. Count an emoji as two columns.

Does it work on Windows?

Yes. The docs have PowerShell and Git Bash examples. With Git Bash, use forward slashes in the command path.

Is the cost figure my real bill?

No. cost.total_cost_usd is an estimate at list price, worked out on your machine. On a subscription you pay the plan price. Behind a gateway, rate_limits.spend_limit is closer to what you’re actually charged.

Final Thoughts: Three Numbers That Tell You What to Do

Most status lines turn into a dashboard: lots of information, very little that changes what you do next. Context percentage tells you when to compact or start fresh. The cache countdown tells you whether stepping away will cost you. The reset time tells you when to start the big job. If a number on your line doesn’t change a decision, drop it.

Start with the script above, add "refreshInterval": 30, and test it with fake input before you trust it. That’s how I found the false bug. If you end up running Claude Code where no one is watching, replace the status line with a written result line and something that reads it every night.

For more on getting Claude Code set up the way you want, start with what the Everything Claude Code repo actually gives you.

Lead Magnet AI Playbook, the operator's AI automation playbook

Get the AI Playbook

Every week: one real job I hand to an agent, what it costs, and what broke. No fluff, unsubscribe anytime.

Lead Magnet - AI Playbook
The AI Playbook — Free Download

📥 FREE: THE AI PLAYBOOK

The exact tools and workflows I use to run a one-person agency. 25 years of marketing experience distilled into an actionable guide. Yours free.

Lead Magnet - AI Playbook

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *