Claude Code status line setup with context tracking — Building Products

 [Mischa Sigtermans](https://mischa.sigtermans.me)

  [ Thoughts ](https://mischa.sigtermans.me/thoughts) [ Books ](https://mischa.sigtermans.me/books) [ About ](https://mischa.sigtermans.me/about)     [← Thoughts](https://mischa.sigtermans.me/thoughts)   January 24, 2026  · AI Open Source

How I set up my Claude Code status line
=======================================

I built a custom Claude Code status line that shows git info, context usage, and turns red at 80%. Here's my setup and why each piece matters.

 ![How I set up my Claude Code status line](/images/how-i-set-up-my-claude-code-status-line.jpg)We're all spending more time with AI than ever. 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.

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?

So I built a custom status line that helps me stay oriented. Nothing fancy. Just the information I actually 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 20%, then it turns Claude Orange.

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

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
---------

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. The `npx` command handles installation automatically, so no setup needed there.

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

```
#!/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"

```

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

```
#!/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`:

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

```

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.

What you can display
--------------------

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

FieldExampleAccessModel nameOpus 4.5`model.display_name`Context %42.5%`context_window.used_percentage`Context remaining57.5%`context_window.remaining_percentage`Tokens used85,000`context_window.total_input_tokens`Tokens remaining115,000`context_window_size - used`Context window size200k`context_window.context_window_size`Session cost$1.42`cost.total_cost_usd`Session duration14m`cost.total_duration_ms`API time8m`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 version2.1.7`version`Project dirstagent`workspace.project_dir`Current dir/Users/...`workspace.current_dir`#### Git info

FieldExampleHowRepo namestagent`basename` of cwdBranchmain`git symbolic-ref`Uncommitted files24 changes`git status --porcelain`Staged files3 staged`git diff --cached`Unstaged files12 modified`git diff`Untracked files5 new`git ls-files --others`Ahead/behind2 ahead, 3 behind`git rev-list --count`Last commit2h ago`git log -1 --format=%cr`Stash count3 stashes`git stash list`Tagv1.2.3`git describe --tags`#### System info

FieldExampleHowTime14:32`date`Hostnamemacbook`hostname`Usermischa`whoami`Node versionv20.1`node -v`PHP version8.4`php -v`Python version3.12`python --version`Battery87%`pmset -g batt`### Some setups to inspire you

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%

```

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.

 *thanks for reading*

Hi, I'm [Mischa](https://mischa.sigtermans.me/about). I've been *shipping products* and *building ventures* for over a decade. First exit at 25, second at 30. Now Partner &amp; CPO at [Ryde Ventures](https://ryde.ventures), an AI venture studio in Amsterdam. Currently shipping [Stagent](https://stagent.com) and [Onoma](https://askonoma.com). Based in Hong Kong. I [write](https://mischa.sigtermans.me/thoughts) about what I learn along the way. [More about me](https://mischa.sigtermans.me/about).

Keep reading: [How I saved 4.7 billion tokens with a Claude Code hook](https://mischa.sigtermans.me/thought/how-i-saved-billions-of-tokens-with-a-claude-code-hook).

   [← Thoughts](https://mischa.sigtermans.me/thoughts)  Connect
-------

  [X](https://x.com/mischamartijn) [LinkedIn](https://linkedin.com/in/mischasigtermans) [GitHub](https://github.com/mischasigtermans)

 © 2026 · [RSS](feed:https://mischa.sigtermans.me/feed)
