Claude Code Status Line: Setup, Examples and Windows Fixes
How to set up the Claude Code status line: the /statusline command, a working script, the fields you can show, and setup on Windows.
Josh Pocock5 min read
AI Coding
Status line
Stride AI Academy
The Claude Code status line is a custom bar at the bottom of the interface that shows whatever your script prints. The fastest setup is to run /statusline with a plain-English request, such as /statusline show model name and context percentage with a progress bar. Claude Code writes the script and updates your settings for you.
It's one of the cheapest upgrades you can make: it runs locally and doesn't use API tokens. Everything below was checked against Anthropic's status line docs on November 5, 2026.
What the status line is good for
The status line keeps the numbers you care about in view, so you don't have to run a command to check them. The most useful things to show are:
- Context used, so you know when a long session is filling up
- Session cost, so spending doesn't surprise you
- Git branch, so you don't commit to the wrong one
- Rate limit usage, so you can see how close you are to your plan's limits
- Model name, so you know what's running
The quick way: use /statusline
Type /statusline followed by what you want:
/statusline show model name and context percentage with a progress barClaude Code generates a script in ~/.claude/ and updates your settings. Approve the file edits if it asks. To remove the status line later, run /statusline delete.
The manual way: write your own script
Doing it yourself takes three steps. These use Bash and jq, which you may need to install. On Windows, skip to the section below.
1. Save this 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"2. Make it executable:
chmod +x ~/.claude/statusline.sh3. Add it to ~/.claude/settings.json:
{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline.sh"
}
}Claude Code reloads settings automatically, so the bar appears as soon as you save. If settings.json already has other entries, add statusLine alongside them.
How it works
Claude Code sends session data to your script as JSON on stdin, then displays whatever your script prints. Each line you print becomes a row, and you can use ANSI color codes for color.
The script runs when a session starts and when a new assistant message arrives, among other events. Rapid updates are batched at 300ms. If you show something based on time, add "refreshInterval": 5 to re-run it every 5 seconds.
Fields you can show
These are the most useful fields in the JSON. The docs list them all.
| Field | What it gives you |
|---|---|
model.display_name |
Current model name |
workspace.current_dir |
Current folder |
context_window.used_percentage |
Share of the context window used |
cost.total_cost_usd |
Estimated session cost |
cost.total_duration_ms |
How long the session has run |
cost.total_lines_added |
Lines of code added |
rate_limits.five_hour.used_percentage |
Use of your 5-hour limit |
rate_limits.seven_day.used_percentage |
Use of your 7-day limit |
effort.level |
Current effort level |
session_name |
Session name |
version |
Claude Code version |
Some fields can be empty, especially early in a session. That's why the script above uses // 0 as a fallback.
Example: show cost and git branch
This version adds the branch and session cost:
#!/bin/bash
input=$(cat)
MODEL=$(echo "$input" | jq -r '.model.display_name')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
BRANCH=$(git branch --show-current 2>/dev/null)
printf '[%s] %s | %s%% context | $%.2f\n' "$MODEL" "$BRANCH" "$PCT" "$COST"The cost is an estimate, worked out on your machine at list price. If you're on a subscription, it's a guide to usage, not what you'll be billed. See how much Claude Code costs for how plans work.
Git commands can be slow in big repositories. If your bar lags, cache the result in a temporary file and refresh it every few seconds.
How to set up the status line on Windows
On Windows, Claude Code runs status line commands through Git Bash if it's installed, and through PowerShell if it isn't. With Git Bash installed, the Bash script above works as it is. Otherwise, use PowerShell.
Save this as C:/Users/username/.claude/statusline.ps1:
$input_json = $input | Out-String | ConvertFrom-Json
$cwd = $input_json.cwd
$model = $input_json.model.display_name
$used = $input_json.context_window.used_percentage
$dirname = Split-Path $cwd -Leaf
if ($used) {
Write-Host "$dirname [$model] ctx: $used%"
} else {
Write-Host "$dirname [$model]"
}Then point your settings at it, using forward slashes in the path:
{
"statusLine": {
"type": "command",
"command": "powershell -NoProfile -File C:/Users/username/.claude/statusline.ps1"
}
}Forward slashes matter, because Git Bash treats unquoted backslashes as escape characters.
Status line not showing?
Work through these in order:
- Check the file runs. Pipe in sample JSON yourself to find script errors.
- Check it's executable on macOS or Linux with
chmod +x. - Check your settings file is valid JSON and uses the right path.
- Check workspace trust. The status line needs you to accept the trust dialog for that folder.
- Check it isn't just hidden. It disappears briefly during some interface moments, such as permission prompts.
If a value shows as empty, it may simply have no data yet. Add a fallback, as in the examples above.
What to set up next
A status line pairs well with the rest of your setup. Next, look at plan mode for safer changes, hooks for automatic checks, or the full Claude Code guide.
FAQ
How do I set up the Claude Code status line?
Run /statusline with a description of what you want, and Claude Code writes the script and settings for you. To do it manually, add a statusLine entry to ~/.claude/settings.json that points to your script.
Does the status line use tokens?
No. It runs locally on your machine and doesn't consume API tokens. If you ask Claude Code to write the script with /statusline, that one request does use tokens like any other message.
How do I show context usage in Claude Code?
Read context_window.used_percentage from the JSON your script receives, or run /statusline show context percentage. Showing it all the time helps you decide when to start a fresh session.
How do I remove the status line?
Run /statusline delete, or remove the statusLine field from your settings file.
Does the Claude Code status line work on Windows?
Yes. It runs through Git Bash when that's installed, or PowerShell when it isn't. For a PowerShell script, call it with powershell -NoProfile -File and use forward slashes in the path.