---
title: "Claude Code statusline: see context, cost and branch at a glance"
date: "2026-12-04T07:00:00.000+02:00"
updated: "2026-11-27T10:19:24.331Z"
tags: ["AI", "Vibe Coding"]
canonical: "https://mariluukkainen.com/blog/claude-code-statusline"
---

The status line is the row at the bottom of Claude Code. You give it a shell script, Claude Code sends that script a JSON blob about the session, and whatever the script prints is shown. Model, folder, git branch, how full the context window is, what the session has cost so far: anything you can compute from that JSON or from your shell.

The number that matters most is context usage. A session gets worse and more expensive as the [context window](/blog/claude-code-context-window) fills, and the status line shows it filling while you work.

## The fast way

Type `/statusline` with a description of what you want:

```text
/statusline show model name, git branch and context percentage with a progress bar
```

Claude writes a script into `~/.claude/` and updates your settings. To remove it, `/statusline delete`.

## The manual way

Save a script, for example `~/.claude/statusline.sh`:

```bash
#!/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)
BRANCH=$(git -C "$DIR" branch --show-current 2>/dev/null)

echo "[$MODEL] ${DIR##*/} ${BRANCH:+($BRANCH)} | ${PCT}% context"
```

Make it executable with `chmod +x ~/.claude/statusline.sh`, then point your settings at it:

```json
{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh"
  }
}
```

Two optional fields: `padding` adds horizontal spacing, and `refreshInterval` re-runs the script every N seconds, for anything time-based such as a clock.

## The fields worth knowing

The JSON on stdin has a lot in it. The useful parts:

- **`model.display_name`**: the model this session runs on
- **`workspace.current_dir`** and **`workspace.project_dir`**: where Claude is now, and where the session started
- **`workspace.git_worktree`**: the worktree name, when you're in one
- **`context_window.used_percentage`** and **`context_window.remaining_percentage`**: how full the context is, already calculated
- **`context_window.context_window_size`**: the maximum, 1,000,000 tokens on current models
- **`cost.total_cost_usd`**: the session's estimated cost at list price
- **`cost.total_duration_ms`**: how long the session has run
- **`rate_limits.five_hour.used_percentage`** and **`rate_limits.seven_day.used_percentage`**: how much of your plan's limits you have used

The cost figure is computed on your machine at list price. On a subscription it measures usage, and you won't get a bill for that amount.

## When it updates

The script runs when the session starts, after each new assistant message, after `/compact`, when the permission mode changes, and on the `refreshInterval` if you set one, plus a few smaller triggers such as a rate-limit reset. Updates are debounced by 300 ms, so a burst of changes runs the script once. Keep the script fast, because it runs often. The example above calls `git` once per run, which is fine. A full `git status` in a big repo on every message is slow.

Colors work with ANSI escape codes, for example `\033[32m` for green, if your terminal supports them.

## What to put in it

1. **Context percentage.** It tells you when to `/clear` between tasks or `/compact` with instructions.
2. **Git branch and worktree.** I keep [parallel sessions in worktrees](/blog/claude-code-worktrees), and right now there are 8 of them in this site's repo alone. The branch name is how you tell the terminals apart.
3. **Model.** Useful if you switch with `/model`, or if your [subagents](/blog/claude-code-subagents) run on different models.
4. **Rate-limit usage**, if you are on a plan and hit the limit.

Leave out anything you won't act on. I wrote about the same problem with monitoring in [stuff I built to manage 100+ apps](/blog/stuff-i-built-to-manage-100-apps): a dashboard nobody checks makes you think something is being watched when nothing is.