Custom Status Lines in Claude Code: Knowing Which Instance You're In

Rod Bland · · 5 min read

When you run multiple Claude Code instances simultaneously, you need to know instantly which one you’re looking at. A custom status line solves this — showing agent identity, model name, context usage, cost, and git branch in a single glanceable row at the bottom of the terminal.

The problem

As I described in my post about building with AI agents, I run 4 Claude Code installations across 2 machines: two on my desktop WSL, two on the VPS. All of them look identical by default. When I switch between tmux panes, there’s a moment of “wait, which one is this?” That moment adds up across a full day of development.

The default Claude Code status line shows basic session info, but it doesn’t tell you which machine or which role the instance is serving. When you’re switching between a VPS session editing production code and a desktop session working on a side project, that distinction matters.

What the status line shows

My custom status line packs six pieces of information into a single row:

  • Agent identity — “CC-VPS” in blue or “CC-WSL” in orange. Instantly tells me which machine I’m on.
  • Model name — shortened to “Opus 4.6” or “Sonnet 4.6” rather than the full model ID.
  • Context bar — a visual progress bar that changes colour as context fills up. This is the most useful part.
  • Cost — session spend in USD.
  • Duration — how long the session has been running.
  • Git branch — the current branch, so I don’t accidentally commit to main.

All of this renders inline using ANSI colour codes. No external tools, no GUI — just text.

The context bar is the killer feature

This was inspired by a YouTube video by Michia Rohrssen called “How to make Claude Code less dumb.” The core insight: never let context usage go past roughly 50%. Once Claude Code’s context window fills up, the model starts losing track of earlier instructions, code structure, and decisions made earlier in the session. Quality degrades noticeably.

The problem is that context usage is invisible by default. You don’t notice it creeping up until the model starts producing worse output.

The context bar makes this intuitive:

  • Green — healthy, plenty of room. Keep working.
  • Yellow — approaching the midpoint. Start wrapping up the current task.
  • Red — context is full. Commit your work and start a new session.

The visual transition from green to yellow is my cue to finish the current task, commit, and start fresh. I no longer run sessions into the ground wondering why the output quality dropped.

How it works

Claude Code supports custom status lines through settings.json. You point it at a shell script, and Claude Code pipes JSON session data into the script via stdin. The script parses the JSON, formats it, and outputs text with ANSI colour codes.

The configuration in ~/.claude/settings.json:

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

The script receives JSON on stdin with fields like contextTokens, maxContextTokens, model, sessionCost, sessionDuration, and gitBranch. It calculates context percentage, picks a colour, builds a progress bar, and writes the formatted output to stdout.

Here’s the core of the context bar logic:

pct=$((contextTokens * 100 / maxContextTokens))

if [ "$pct" -lt 40 ]; then
  bar_color="\033[32m"   # green
elif [ "$pct" -lt 65 ]; then
  bar_color="\033[33m"   # yellow
else
  bar_color="\033[31m"   # red
fi

filled=$((pct * bar_width / 100))
empty=$((bar_width - filled))
bar="${bar_color}$(printf '█%.0s' $(seq 1 $filled))$(printf '░%.0s' $(seq 1 $empty))\033[0m"

The agent identity colour is set by hostname detection — if the hostname matches the VPS, it renders blue; otherwise, orange for WSL.

Dotfiles architecture

The statusline script lives in a dotfiles git repo (rodbland2021/dotfiles), symlinked into place on both machines:

ln -sf ~/repos/dotfiles/claude/statusline.sh ~/.claude/statusline.sh

Edit on either machine, commit and push, pull on the other. One script, two machines, always in sync. The settings.json configuration is identical on both — only the hostname detection inside the script changes the output.

Hot-reload

One detail worth noting: Claude Code hot-reloads settings.json. When you change the status line configuration or update the script, the changes take effect immediately in running sessions. No restart needed. This makes iteration fast — edit the script, save, and the status line updates on the next tick.

Setup summary

  1. Create a shell script that reads JSON from stdin and outputs formatted text.
  2. Add a statusLine object to ~/.claude/settings.json with type: "command" and the path to your script.
  3. Claude Code starts piping session data to your script automatically.

The entire setup is a single shell script and one JSON config entry. No dependencies, no build step, no framework.

Why this matters

This is a small thing that compounds. Every time I glance at the terminal, I know which instance I’m in, what model it’s running, how much context is left, what it’s cost me, and what branch I’m on. No clicking, no switching tabs, no mental overhead.

The context bar alone has changed how I work. I used to run sessions until the output got noticeably worse, then wonder what happened. Now I see the bar turn yellow and I wrap up cleanly. Better output, fewer wasted tokens, less frustration.

If you’re running even two Claude Code sessions, a custom status line is worth the 20 minutes it takes to set up.