Three-Line Cockpit

Model, context, lines changed and branch on the first line; a context bar with token counts on the second; session cost on the third. No network calls, just stdin and local git.

Before you install

  • This version was reviewed before it was listed on Jul 6, 2026
  • Doesn't ask to connect to the internet
  • Needs jq, and git for the branch name.
  • The +added/-removed numbers are Claude Code's session line counts, not your uncommitted git diff.
  • With no used_percentage in the input (new session, just after /compact) it shows 0% and an empty bar.
Not showing after you paste? Fix it

Preview

Clean repo
🤖 Opus 4.8 │ 📊 22% │ ✏️ +128/-34 │ 🔀 main 📐 CTX ▰▰▱▱▱▱▱▱▱▱ 22% 44K / 200K tokens 💰 $0.41
New session
🤖 Opus 4.8 │ 📊 0% │ 🔀 main 📐 CTX ▱▱▱▱▱▱▱▱▱▱ 0% 0 / 200K tokens 💰 --
Dirty branch
🤖 Sonnet 4.6 │ 📊 48% │ ✏️ +128/-34 │ 🔀 feat/auth 📐 CTX ▰▰▰▰▰▱▱▱▱▱ 48% 96K / 200K tokens 💰 $0.41
Near-full
🤖 Opus 4.8 │ 📊 91% │ ✏️ +128/-34 │ 🔀 main 📐 CTX ▰▰▰▰▰▰▰▰▰▱ 91% 182K / 200K tokens 💰 $4.12
1M context
🤖 Fable 5 │ 📊 64% │ ✏️ +128/-34 │ 🔀 main 📐 CTX ▰▰▰▰▰▰▱▱▱▱ 64% 640K / 1M tokens 💰 $0.41
Post-compact
🤖 Haiku 4.5 │ 📊 0% │ ✏️ +128/-34 │ 🔀 main 📐 CTX ▱▱▱▱▱▱▱▱▱▱ 0% 0 / 200K tokens 💰 $0.41
Worktree
🤖 Opus 4.8 │ 📊 37% │ ✏️ +128/-34 │ 🔀 worktree-feature 📐 CTX ▰▰▰▰▱▱▱▱▱▱ 37% 74K / 200K tokens 💰 $0.41
Non-git
🤖 Opus 4.8 │ 📊 22% │ ✏️ +128/-34 📐 CTX ▰▰▱▱▱▱▱▱▱▱ 22% 44K / 200K tokens 💰 $0.41

In Claude Desktop

Three-Line Cockpit in Claude Desktop

Recorded with statusline-anywhere.

What it does

Three lines: model, context percentage, lines changed and git branch; a 10-segment context bar with token counts; then the session cost. It reads only stdin and local git.

Written in
Bash
Network access
None requested
Works in
Terminal

How it works

  1. Reads used_percentage, cost.total_lines_added and total_cost_usd from stdin JSON.
  2. Estimates used tokens as window size times that percentage, so 22% of 200K reads 44K.
  3. The percentage and bar go yellow at 50% and red at 80%, as in the 64% and 91% previews.
  4. Leaves out the branch outside a repo and shows 💰 -- while the cost is still zero.

Source

#!/bin/bash
# Claude Code statusline script (ToS-safe version)
# Line 1: Model | Context% | +added/-removed | git branch
# Line 2: Context window progress bar (detailed)
# Line 3: Session cost | Version
#
# This version uses ONLY stdin data provided by Claude Code.
# No external API calls, no OAuth token extraction, no keychain access.
# Fully compliant with Anthropic Consumer Terms of Service.

set -euo pipefail

# ---------- Read stdin (Claude Code provides JSON) ----------
input=$(cat)

# ---------- ANSI Colors ----------
readonly GREEN=$'\e[38;2;151;201;195m'
readonly YELLOW=$'\e[38;2;229;192;123m'
readonly RED=$'\e[38;2;224;108;117m'
readonly GRAY=$'\e[38;2;74;88;92m'
readonly RESET=$'\e[0m'
readonly DIM=$'\e[2m'

# ---------- Color by percentage ----------
color_for_pct() {
  local pct="${1:-0}"
  if [[ -z "$pct" || "$pct" == "null" ]]; then
    printf '%s' "$GRAY"
    return
  fi
  local ipct
  ipct=$(printf "%.0f" "$pct" 2>/dev/null) || ipct=0
  if (( ipct >= 80 )); then
    printf '%s' "$RED"
  elif (( ipct >= 50 )); then
    printf '%s' "$YELLOW"
  else
    printf '%s' "$GREEN"
  fi
}

# ---------- Progress bar (10 segments) ----------
progress_bar() {
  local pct="${1:-0}"
  local filled
  filled=$(awk "BEGIN{v=int($pct / 10 + 0.5); if(v>10)v=10; if(v<0)v=0; printf \"%d\", v}" 2>/dev/null) || filled=0
  local bar=""
  local i
  for (( i=1; i<=10; i++ )); do
    if (( i <= filled )); then
      bar+="▰"
    else
      bar+="▱"
    fi
  done
  printf '%s' "$bar"
}

# ---------- Safe JSON parsing (no eval) ----------
parse_json() {
  local json="$1"
  local query="$2"
  local default="${3:-}"
  local result
  result=$(printf '%s' "$json" | jq -r "$query" 2>/dev/null) || result=""
  if [[ -z "$result" || "$result" == "null" ]]; then
    printf '%s' "$default"
  else
    printf '%s' "$result"
  fi
}

# ---------- Parse stdin fields ----------
model_name=$(parse_json "$input" '.model.display_name // empty' 'Unknown')
used_pct=$(parse_json "$input" '.context_window.used_percentage // 0' '0')
remaining_pct=$(parse_json "$input" '.context_window.remaining_percentage // 100' '100')
ctx_size=$(parse_json "$input" '.context_window.context_window_size // 0' '0')
cwd=$(parse_json "$input" '.cwd // empty' '')
lines_added=$(parse_json "$input" '.cost.total_lines_added // 0' '0')
lines_removed=$(parse_json "$input" '.cost.total_lines_removed // 0' '0')
total_cost=$(parse_json "$input" '.cost.total_cost_usd // 0' '0')

# ---------- Git branch ----------
git_branch=""
if [[ -n "$cwd" && -d "$cwd" ]]; then
  git_branch=$(git -C "$cwd" --no-optional-locks rev-parse --abbrev-ref HEAD 2>/dev/null) || true
fi

# ---------- Line stats ----------
git_stats=""
if (( ${lines_added:-0} > 0 )) 2>/dev/null || (( ${lines_removed:-0} > 0 )) 2>/dev/null; then
  git_stats="+${lines_added}/-${lines_removed}"
fi

# ---------- Context window formatting ----------
ctx_pct_int=$(printf "%.0f" "${used_pct:-0}" 2>/dev/null) || ctx_pct_int=0

# Format context size (e.g., 200000 -> 200K)
format_tokens() {
  local tokens="${1:-0}"
  if (( tokens >= 1000000 )); then
    awk "BEGIN{printf \"%.0fM\", $tokens / 1000000}"
  elif (( tokens >= 1000 )); then
    awk "BEGIN{printf \"%.0fK\", $tokens / 1000}"
  else
    printf '%s' "$tokens"
  fi
}

ctx_size_display=$(format_tokens "$ctx_size")

# Used tokens (approximate)
used_tokens=0
if (( ctx_size > 0 )); then
  used_tokens=$(awk "BEGIN{printf \"%.0f\", $ctx_size * $used_pct / 100}" 2>/dev/null) || used_tokens=0
fi
used_tokens_display=$(format_tokens "$used_tokens")

# ---------- Cost formatting ----------
cost_display=""
if [[ -n "$total_cost" && "$total_cost" != "0" ]]; then
  cost_display=$(awk "BEGIN{printf \"\$%.2f\", $total_cost}" 2>/dev/null) || cost_display=""
fi

# ---------- Separator ----------
SEP="${GRAY} │ ${RESET}"

# ========== Line 1: Model | Context% | Changes | Branch ==========
ctx_color=$(color_for_pct "$ctx_pct_int")

line1="🤖 ${model_name}${SEP}${ctx_color}📊 ${ctx_pct_int}%${RESET}"

if [[ -n "$git_stats" ]]; then
  line1+="${SEP}✏️  ${GREEN}${git_stats}${RESET}"
fi

if [[ -n "$git_branch" ]]; then
  line1+="${SEP}🔀 ${git_branch}"
fi

# ========== Line 2: Context window progress bar ==========
ctx_bar_color=$(color_for_pct "$ctx_pct_int")
ctx_bar=$(progress_bar "$ctx_pct_int")

line2="${ctx_bar_color}📐 CTX  ${ctx_bar}  ${ctx_pct_int}%${RESET}"
if (( ctx_size > 0 )); then
  line2+="  ${DIM}${used_tokens_display} / ${ctx_size_display} tokens${RESET}"
fi

# ========== Line 3: Session cost ==========
line3=""
if [[ -n "$cost_display" ]]; then
  line3="${GREEN}💰 ${cost_display}${RESET}"
else
  line3="${DIM}💰 --${RESET}"
fi

# ---------- Output ----------
printf '%s\n' "$line1"
printf '%s\n' "$line2"
printf '%s' "$line3"

Badge for your README

Own this listing? Add it to your README. The badge shows the install count as it grows.

Reviewed on statuslin.es
[![Reviewed on statuslin.es](https://statuslin.es/badge/c/three-line-cockpit-2864c871.svg)](https://statuslin.es/c/three-line-cockpit-2864c871?utm_source=readme-badge)

Or show the preview card:

Preview on statuslin.es
[![Preview on statuslin.es](https://statuslin.es/og/c/three-line-cockpit-2864c871.png)](https://statuslin.es/c/three-line-cockpit-2864c871?utm_source=readme-badge)

More status lines

  • 115 installs
Opus 4.8 [high] ~/app main 16:20:55 | ⛁ ██░░░░░░░░ 22% | 5h ●◔○○○ 26% ↻2h7m | 7d ◔○○○○○○ 7% ↻2d1h │ $0.41 ⏱ 10m
  • 57 installs
Opus 4.8 high ✦ │ ctx 22% │ app (main) │ PR #1287 ● │ $0.41 · 10m +128 -34 Session ● ● ● ● ● ● ● ● ○ ○ ○ 74% left Resets in 2h 6m Weekly ● ● ● ● ● ● ● ● ● ● ○ 93% left Resets in 2d 0h Fable ● ● ● ● ● ● ● ● ● ○ ○ 85% left Resets in 2d 0h ◐ Read:index.ts ✓ Read×1 ✓ Bash×1 ✓ Edit×1 ✓ Grep×1 ◐ code-reviewer Review the change for regressions
Model: Opus 4.8 | Thinking: high | Context: [▰▰▱▱▱▱▱▱▱▱] 45k/200k (22%) | cwd: ~/app | ⎇ main | (+0,-0) Cost: $0.41 | Block: 2hr 6m | Weekly: 7.0% | Session: 10m | In: 916.7 t/s | Out: 29.2 t/s | Cached: 2k | Session: [▰▱▱▱▱] 26.0% Mem: 0.8G/1.0G | (*゚∀゚*) | Session ID: b8e1c0d2-4a6f-4e2a-9c1b-3f5d7a9e2c10
app · main · Opus 4.8 · high ctx 22% 44k · 5h 26% ↻2h6m · 7d 7% ↻2d0h · cost $0.41 · msg $0.757
  • 5 installs
Opus 4.8 (200K) high | app (main) ██░░░░░░░░ 22% 200K | 5h 26% ⇣32% 2h 7d 7% ⇣63% 2d
🤖 Opus 4.8 ⚡high 💡 │ 🎨 default │ ✅ git clean │ no env 📂 /home/user/app 🌿(main) │ 💰 0.41$ │ ⏰ 10m 🧠 Context █████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 22% used (44k/200k) 🚀 5H Limit ██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 26% (Resets in 2h6m) 🌟 7D Limit ███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 7% (Resets Oct 20 at 3pm)

Related mods

Deck in Claude Desktop

A cockpit for Claude Code: plan bars and subagent strips, context, usage limits with reset countdowns and burn rates, spend, the model route and a pet. Six bar styles, three collapsed looks. CLI and Desktop.

Flightdeck in Claude Desktop

Flightdeck: a live agent dashboard for Claude Code. Main model vitals, an on-call architect, every permission check, subagent cards and swimlanes, a turn receipt and a session log, all from real session events