Back to Blog

Claude Code statusline: show the model, context and cost at a glance

Alex Kim
7 min read
Claude Code statusline: show the model, context and cost at a glance

Last updated: November 24, 2026

TL;DR

The Claude Code statusline is a row at the bottom of the session that runs a shell command you choose. Claude Code sends that command a block of JSON about the session on stdin, and shows whatever it prints. The fastest setup is one line: /statusline show model name and context percentage with a progress bar, and Claude Code writes the script into ~/.claude/ and updates your settings. To build it yourself, point a statusLine entry in ~/.claude/settings.json at a script. It runs locally and uses no API tokens. Everything below comes from Anthropic's statusline docs.

Set it up with /statusline

Type /statusline followed by what you want to see, in plain words:

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

Claude Code generates a script file in ~/.claude/ and adds it to your settings. Approve the file edits if it asks. To remove it later, run /statusline again and ask it to delete or clear the status line, or delete the statusLine field from your settings yourself.

Set it up by hand

Three steps give you the same result with a script you wrote.

  1. Write a script that reads JSON and prints a line. This one, from Anthropic's walkthrough, uses jq (install it if you don't have it). Save it as ~/.claude/statusline.sh:
#!/bin/bash
input=$(cat)
MODEL=$(echo "$input" | jq -r '.model.display_name')
DIR=$(echo "$input" | jq -r '.workspace.current_dir')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
echo "[$MODEL] ๐Ÿ“ ${DIR##*/} | ${PCT}% context"
  1. Make it executable with chmod +x ~/.claude/statusline.sh.
  2. Point your settings at it. Add this to ~/.claude/settings.json, or to a project's settings to share it:
{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh"
  }
}

Claude Code reloads settings on its own and runs the script as soon as you save. Our settings guide covers which settings file wins when a key appears in more than one.

Three optional fields tune it:

FieldWhat it does
paddingExtra horizontal spacing, in characters, on top of the built-in spacing. Defaults to 0
refreshIntervalRe-runs the command every N seconds (minimum 1) as well as on events. Use it for a clock, or when background work changes git state while the session is idle
hideVimModeIndicatorHides the built-in vim mode text when your script shows vim.mode itself

What it can show

The JSON carries more than the model and folder. The fields most status lines use:

You wantField
Modelmodel.display_name
Folderworkspace.current_dir, and workspace.project_dir for where the session started
Context usedcontext_window.used_percentage, or remaining_percentage
Session costcost.total_cost_usd, an estimate at list price that may differ from your bill
Lines changedcost.total_lines_added, cost.total_lines_removed
Plan limitsrate_limits.five_hour.used_percentage, rate_limits.seven_day.used_percentage
Effort leveleffort.level
Open pull requestpr.number, pr.url, pr.review_state
Session namesession_name

Some fields come and go. rate_limits appears only for Pro, Max and Ultra subscribers (or behind a Claude apps gateway with a spend limit), and only after the first response; effort appears only when the model supports it; pr only while the branch has an open pull request. Use a fallback such as // 0 or // empty in jq so a missing field prints nothing instead of breaking the line.

If the context figure looks lower than /context, that's expected: the status line reports the last API response, while /context adds an estimate for messages since. Our guides to token usage and session limits explain what those numbers mean for your plan, and our /compact guide covers what to do when the context figure climbs.

Your script can print several lines (each echo is a row), ANSI colors, and clickable OSC 8 links in terminals that support them. Claude Code passes the terminal width in COLUMNS; keep each line at least four columns narrower so it isn't cut off.

Keep it fast

The script runs when a session starts or resumes, then after each new assistant message, when /compact finishes, when the permission mode or vim mode changes, and on your refreshInterval if you set one. Updates are batched over 300ms, and if a new update arrives while your script is still running, Claude Code cancels the running one. So a slow script means a stale line.

Commands such as git status can be slow in a big repository. Anthropic's docs cache git output to a temp file named with the session_id from the JSON and refresh it every five seconds; don't name the cache after the process ID, which changes on every run. Test a script before wiring it in by piping sample JSON into it:

echo '{"model":{"display_name":"Opus"},"workspace":{"current_dir":"/home/user/project"},"context_window":{"used_percentage":25},"session_id":"test-session-abc"}' | ./statusline.sh

On Windows

Claude Code runs the command through Git Bash when it's installed, and through PowerShell otherwise. Write paths in command with forward slashes: Git Bash eats backslashes and the command fails with no visible error. To use a PowerShell script, call it through powershell, as in powershell -NoProfile -File C:/Users/username/.claude/statusline.ps1.

Why the status line is blank

  • ๐Ÿ” The folder isn't trusted yet. The status line runs a shell command, so it follows the same workspace trust rule as hooks. Accept the trust dialog and restart.
  • ๐Ÿงช The script failed. Claude Code shows output only when the script exits with code 0 and prints to stdout. Run it by hand with sample JSON.
  • ๐Ÿ”‘ It isn't executable. Run chmod +x on it.
  • ๐Ÿข Your organization manages hooks. With allowManagedHooksOnly in managed settings, only a status line from managed settings runs. A disableAllHooks setting outside managed settings switches it off too. Our hooks guide covers how those settings work.

Starting Claude Code with its debug flag logs the script's errors on each run.

Frequently asked questions

How do I set up the Claude Code statusline?

Run /statusline followed by what you want to see, such as /statusline show model name and context percentage with a progress bar. Claude Code writes a script into ~/.claude/ and updates your settings. Or add a statusLine entry with type command to ~/.claude/settings.json and point it at your own script.

Does the Claude Code statusline use tokens?

No. The status line runs locally on your machine and does not consume API tokens.

What can the Claude Code statusline show?

Anything your script prints from the session JSON: the model, the folder, context window use, estimated session cost, lines changed, plan rate limits, effort level, the open pull request and the session name, plus anything else your script can compute, such as the git branch.

Why is my Claude Code status line blank?

Usually the folder isn't trusted yet, the script exits with an error or prints nothing, or the script isn't executable. If your organization sets allowManagedHooksOnly, only a status line from managed settings runs.

How often does the Claude Code statusline update?

When a session starts or resumes, after each new assistant message, when /compact finishes, when the permission or vim mode changes, and every N seconds if you set refreshInterval. Updates are batched over 300 milliseconds.

Next: the commands around it

A status line tells you when to act; the commands are how you act. Our Claude Code CLI guide lists the slash commands, flags and shortcuts that go with it, from /context and /compact to resuming a session.

#claude-code#Statusline#Context Window#Settings#ai-agents
Free assessment

Stop guessing. Score your first workflow.

Score one workflow in about five minutes. Nine questions, a grade, and the specific gap holding it back - no call required.