# How I set up my Claude Code status line

Lately I'm almost living with Claude Code, jumping between four to six projects on any given day. [Stagent](https://stagent.com) features, Ryde Ventures products, side projects, this blog. What keeps me oriented is a custom Claude Code status line: one row under the prompt with the repo, the branch, my uncommitted changes, and how much of the context window I've used.

![How I set up my Claude Code status line](/images/how-i-set-up-my-claude-code-status-line-photo.jpg)

AI makes us efficient. But efficiency means nothing if you lose track of where you are. Which repo am I in? How much context have I burned through? Do I have uncommitted work?

This post has the two scripts and the one `settings.json` entry that build it, plus every field Claude Code hands your script if you want something else. Nothing fancy. Just the information I need.

## What I actually need to see

My status line shows four pieces of information:

```
stagent · development · 14↑ · 42%
```

That is: repo name, git branch, uncommitted changes, and context window percentage. Plain text. No colors except when the context hits 80%, then it turns red.

I prefer things simple. No emojis. No powerline arrows. No fancy themes. Less is more.

My own line has one more word in front: the Claude Code account the session runs on, so it reads `ryde` before the repo name. I run several accounts, and [Clauset](/project/clauset) prints that name from the same JSON. With one account you don't need it.

## The problem with defaults

Claude Code does not prominently display context usage during a session. You can check it manually, but by the time you think to look, you might already be at 90%. And when context fills up, AI quality degrades. Responses get worse. The model starts forgetting earlier parts of your conversation.

I also jump between repositories constantly. Without visual confirmation, it's easy to lose track of where you are and what state your work is in.

The uncommitted changes count solves a different problem. It's a gentle reminder before I close a session or switch context. If that number isn't zero, I have work that isn't saved to git yet.

## The setup: two scripts and one settings.json entry

A Claude Code status line is any command you point the `statusLine` setting at. Claude Code pipes a JSON object with the session's data into that command and shows whatever it prints.

My configuration uses a wrapper pattern: one main script that combines two sources of information. The wrapper uses [ccstatusline](https://github.com/sirmalloc/ccstatusline) for context percentage. ccstatusline can draw a whole status line on its own, with themes and a configuration UI. I only want one number from it, so I wrap it and keep everything else plain. The `npx` command handles installation automatically, so no setup needed there.

Create the wrapper script at `~/.claude/statusline-wrapper.sh`:

```bash
#!/bin/bash

input=$(cat)
git_info=$(echo "$input" | bash ~/.claude/statusline-command.sh)
context_pct=$(echo "$input" | npx ccstatusline 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g; s/ //g; s/%//')
pct_num=${context_pct%%.*}

if [[ $pct_num =~ ^[0-9]+$ ]] && (( pct_num >= 80 )); then
  context_display=$'\033[1;38;2;204;139;137m'"${pct_num}%"$'\033[0m'
else
  context_display="${pct_num}%"
fi

printf '%s · %s' "$git_info" "$context_display"
```

Claude Code now hands over the percentage itself, as `context_window.used_percentage`. If you'd rather skip ccstatusline, swap the `context_pct` line for one that reads it with `jq`:

```bash
context_pct=$(echo "$input" | jq -r '.context_window.used_percentage // 0')
```

The field is empty until the first response comes back, so `// 0` shows 0% instead of nothing.

Then the git info script at `~/.claude/statusline-command.sh`:

```bash
#!/bin/bash

input=$(cat)
cwd=$(echo "$input" | sed -n 's/.*"current_dir":"\([^"]*\)".*/\1/p')
cwd_display=${cwd/#$HOME/\~}

if git -C "$cwd" rev-parse --git-dir &>/dev/null; then
  repo_name=${cwd##*/}
  branch=$(git -C "$cwd" --no-optional-locks symbolic-ref --short HEAD 2>/dev/null) || \
  branch=$(git -C "$cwd" --no-optional-locks rev-parse --short HEAD 2>/dev/null)
  uncommitted=$(git -C "$cwd" --no-optional-locks status --porcelain 2>/dev/null | wc -l)

  if (( uncommitted > 0 )); then
    printf '%s · %s · %d↑' "$repo_name" "$branch" "$uncommitted"
  else
    printf '%s · %s' "$repo_name" "$branch"
  fi
else
  printf '%s' "$cwd_display"
fi
```

Make both scripts executable with `chmod +x ~/.claude/statusline-*.sh`.

Finally, add the status line to your Claude Code settings at `~/.claude/settings.json` (the rest of [my Claude Code settings](/thought/my-claude-code-settings) has its own post):

```json
{
  "statusLine": {
    "type": "command",
    "command": "bash ~/.claude/statusline-wrapper.sh",
    "padding": 0
  }
}
```

`padding` sets the extra spacing around the line, in characters; I keep it at 0. The line redraws when the session changes. To redraw on a clock as well, add `"refreshInterval"` with a number of seconds.

To skip the scripts, the `/statusline` command takes a description, such as `/statusline show model name and context percentage`, writes a script into `~/.claude` and points your settings at it.

## Why the 80% threshold

The context window matters more than most people realize. Claude Code reserves roughly 40k tokens as a buffer, and auto-compact triggers when you hit that threshold. But by the time auto-compact runs, the AI has already been struggling with a full context for several exchanges.

I found 80% to be a good warning point. When the number turns red, I know to either compact the conversation or start fresh. This simple visual cue has saved me from plenty of degraded responses. Keeping the context from filling up with noise in the first place is [what my rtk hook does](/thought/how-i-saved-billions-of-tokens-with-a-claude-code-hook).

## What you can display: every field Claude Code passes in

My setup is intentionally minimal. But the status line can show almost anything. Claude Code passes a JSON object to your script with session data, and you can pull in external information from git, system commands, or anything else your shell can access.

Here is everything available to you:

#### Session data

| Field | Example | Access |
|-------|---------|--------|
| Model name | Opus 4.5 | `model.display_name` |
| Context % | 42.5% | `context_window.used_percentage` |
| Context remaining | 57.5% | `context_window.remaining_percentage` |
| Tokens used | 85,000 | `context_window.total_input_tokens` |
| Tokens remaining | 115,000 | `context_window_size - used` |
| Context window size | 200k | `context_window.context_window_size` |
| Session cost | $1.42 | `cost.total_cost_usd` |
| Session duration | 14m | `cost.total_duration_ms` |
| API time | 8m | `cost.total_api_duration_ms` |
| Lines added | +142 | `cost.total_lines_added` |
| Lines removed | -38 | `cost.total_lines_removed` |
| Net lines | +104 | `added - removed` |
| Claude version | 2.1.7 | `version` |
| Project dir | stagent | `workspace.project_dir` |
| Current dir | /Users/... | `workspace.current_dir` |
| 5-hour limit used | 41% | `rate_limits.five_hour.used_percentage` |
| 7-day limit used | 63% | `rate_limits.seven_day.used_percentage` |
| Limit resets | 16:00 | `rate_limits.five_hour.resets_at` (Unix seconds) |
| Effort level | high | `effort.level` |
| Pull request | #128 | `pr.number` |
| Worktree | feat-billing | `worktree.name` |

The `rate_limits` block only shows up for Pro, Max and Ultra subscribers, after the first response of a session, and either window can be missing on its own. `effort`, `pr` and `worktree` are missing when they don't apply, so give each a fallback.

#### Git info

| Field | Example | How |
|-------|---------|-----|
| Repo name | stagent | `basename` of cwd |
| Branch | main | `git symbolic-ref` |
| Uncommitted files | 24 changes | `git status --porcelain` |
| Staged files | 3 staged | `git diff --cached` |
| Unstaged files | 12 modified | `git diff` |
| Untracked files | 5 new | `git ls-files --others` |
| Ahead/behind | 2 ahead, 3 behind | `git rev-list --count` |
| Last commit | 2h ago | `git log -1 --format=%cr` |
| Stash count | 3 stashes | `git stash list` |
| Tag | v1.2.3 | `git describe --tags` |

#### System info

| Field | Example | How |
|-------|---------|-----|
| Time | 14:32 | `date` |
| Hostname | macbook | `hostname` |
| User | mischa | `whoami` |
| Node version | v20.1 | `node -v` |
| PHP version | 8.4 | `php -v` |
| Python version | 3.12 | `python --version` |
| Battery | 87% | `pmset -g batt` |

### Status line examples to start from

With all this data, you can build a status line that fits exactly how you work:

**Minimal** - just the essentials:
```
stagent · main · 12%
```

**Cost-conscious** - track what you're spending:
```
Opus · $1.42 · +142/-38 lines · 45%
```

**Git-heavy** - for complex branching workflows:
```
stagent · feat/billing · 2 ahead, 1 behind · 3 staged · 12%
```

**Time-aware** - know how long you've been at it:
```
14:32 · stagent · main · 8m active · 25%
```

**Limit-aware** - watch your plan's usage limits:
```
stagent · main · 42% · 5h 41% · 7d 63%
```

The two limit numbers come from one `jq` line:

```bash
limits=$(echo "$input" | jq -r '[(.rate_limits.five_hour.used_percentage // empty | "5h \(floor)%"), (.rate_limits.seven_day.used_percentage // empty | "7d \(floor)%")] | join(" · ")')
```

You can add threshold colors that change at certain percentages, use icons if your terminal supports them, or go full powerline with arrow separators.

Tools like [ccstatusline](https://github.com/sirmalloc/ccstatusline) offer multi-line support, powerline themes, and an interactive configuration UI. The [official documentation](https://code.claude.com/docs/en/statusline) has the complete JSON schema if you want to go deep.

I just prefer plain.

## The philosophy

This connects to how I think about building products. Functionality first. Ship what works. Add complexity only when you actually need it.

I wrote about this same principle in the context of [AI coding with sub-agents](/thought/taylor-otwell-is-immortal-and-costs-200-month): the goal is code that is 'simple and disposable and easy to change'. The same applies to tooling. My status line does exactly what I need. When I need it to do more, I will add more.

For now, four pieces of information and one color change is enough.
