Plain Python Bar

One cross-platform Python line: model, user, folder, git branch, a color-coded context bar, input, output and cache token counts, and session cost. Standard library only, no network calls.

Before you install

  • This version was reviewed before it was listed on Oct 18, 2026
  • Doesn't ask to connect to the internet
  • Calls git on every render; outside a repo the branch is left out.
  • Token counts come from context_window.current_usage (input ↑, output ↓, cache reads c), not totals.
  • Shows your login name from $USERNAME or $USER, and prints nothing if stdin isn't valid JSON.
Not showing after you paste? Fix it

Preview

Clean repo
Opus 4.8 | user | ~/app | main | ██░░░░░░░░ 22% | 37000↑ 1400↓ 2000c | $0.4100
New session
Opus 4.8 | user | ~/app | main | $0.0000
Dirty branch
Sonnet 4.6 | user | ~/app | feat/auth | █████░░░░░ 48% | 89000↑ 1400↓ 2000c | $0.4100
Near-full
Opus 4.8 | user | ~/app | main | █████████░ 91% | 175000↑ 1400↓ 2000c | $4.1200
1M context
Fable 5 | user | ~/app | main | ██████░░░░ 64% | 633000↑ 1400↓ 2000c | $0.4100
Post-compact
Haiku 4.5 | user | ~/app | main | $0.4100
Worktree
Opus 4.8 | user | ~/.wt/feature | worktree-feature | ████░░░░░░ 37% | 67000↑ 1400↓ 2000c | $0.4100
Non-git
Opus 4.8 | user | ~/scratch | ██░░░░░░░░ 22% | 37000↑ 1400↓ 2000c | $0.4100

In Claude Desktop

Plain Python Bar in Claude Desktop

Recorded with statusline-anywhere.

What it does

One line with the model, your user name, the folder, git branch, a 10-cell context bar, token counts and the session cost in dollars, split by pipes.

Written in
Python
Network access
None requested
Works in
Terminal

How it works

  1. Reads the model, folder, context window and cost.total_cost_usd from the stdin JSON.
  2. Runs git symbolic-ref for the branch, falling back to the short commit hash.
  3. The bar is green under 50% used, yellow from 50% and red from 80%.
  4. Cost turns yellow at $5 and red at $20. A new session shows no bar or token counts.

Source

"""
statusline.py — Claude Code custom statusline renderer.

Reads a JSON event payload from stdin (emitted by Claude Code on every turn)
and prints a single ANSI-colored status line to stdout. Renders the model
display name, current user, working directory (with home collapsed to ``~``),
active git branch, a color-coded context window usage bar (green / yellow /
red thresholds), and token counts. Always exits 0 so it can never block
Claude Code — missing fields are silently skipped.

Intended to be referenced from Claude Code's ``statusLine`` setting (see
``statusline-command.sh`` for the wrapper) or installed to
``~/.claude/statusline.py``.

:file: statusline/statusline.py
:module: Claude-Code-Agent-Monitor.statusline
:author: Son Nguyen <hoangson091104@gmail.com>
:maintainer: Son Nguyen (a.k.a. David Nguyen, hoangsonww)
:copyright: (c) 2026 Son Nguyen
:license: MIT
:repository: https://github.com/hoangsonww/Claude-Code-Agent-Monitor
:requires: Python 3.6+
:encoding: utf-8

@author Son Nguyen <hoangson091104@gmail.com>
"""

__file_name__ = "statusline.py"
__module__ = "Claude-Code-Agent-Monitor.statusline"
__author__ = "Son Nguyen"
__email__ = "hoangson091104@gmail.com"
__maintainer__ = "Son Nguyen"
__copyright__ = "Copyright (c) 2026 Son Nguyen"
__license__ = "MIT"
__version__ = "1.0.0"
__status__ = "Production"
__repository__ = "https://github.com/hoangsonww/Claude-Code-Agent-Monitor"

import sys
import json
import os
import subprocess

sys.stdout.reconfigure(encoding='utf-8')

CYAN    = '\033[0;36m'
GREEN   = '\033[0;32m'
YELLOW  = '\033[0;33m'
MAGENTA = '\033[0;35m'
RED     = '\033[0;31m'
DIM     = '\033[2m'
RESET   = '\033[0m'

raw = sys.stdin.read().strip()
if not raw:
    sys.exit(0)

try:
    data = json.loads(raw)
except Exception:
    sys.exit(0)

parts = []

# Model
model = (data.get('model') or {}).get('display_name', '')
if model:
    parts.append(f"{CYAN}{model}{RESET}")

# User
user = os.environ.get('USERNAME') or os.environ.get('USER', '')
if user:
    parts.append(f"{GREEN}{user}{RESET}")

# CWD — strip home prefix
cwd = (data.get('workspace') or {}).get('current_dir') or data.get('cwd', '')
if cwd:
    home = os.path.expanduser('~')  # C:\Users\nguyens6
    if cwd.startswith(home):
        cwd = '~' + cwd[len(home):].replace('\\', '/')
    else:
        cwd = cwd.replace('\\', '/')
    parts.append(f"{YELLOW}{cwd}{RESET}")

# Git branch
git_dir = (data.get('workspace') or {}).get('current_dir') or data.get('cwd', '')
if git_dir:
    try:
        branch = subprocess.check_output(
            ['git', '-C', git_dir, '--no-optional-locks', 'symbolic-ref', '--short', 'HEAD'],
            stderr=subprocess.DEVNULL
        ).decode().strip()
    except Exception:
        try:
            branch = subprocess.check_output(
                ['git', '-C', git_dir, '--no-optional-locks', 'rev-parse', '--short', 'HEAD'],
                stderr=subprocess.DEVNULL
            ).decode().strip()
        except Exception:
            branch = ''
    if branch:
        parts.append(f"{MAGENTA}{branch}{RESET}")

# Context bar
ctx = data.get('context_window') or {}
used_pct = ctx.get('used_percentage')
if used_pct is not None:
    bar_len = 10
    filled = round(bar_len * used_pct / 100)
    bar = '█' * filled + '░' * (bar_len - filled)
    color = RED if used_pct >= 80 else YELLOW if used_pct >= 50 else GREEN
    parts.append(f"{color}{bar} {used_pct}%{RESET}")

# Tokens
usage = ctx.get('current_usage') or {}
in_tok  = usage.get('input_tokens')
out_tok = usage.get('output_tokens')
cache   = usage.get('cache_read_input_tokens')
if in_tok is not None and out_tok is not None:
    tok_parts = [f"{GREEN}{in_tok}↑{RESET}", f"{CYAN}{out_tok}↓{RESET}"]
    if cache:
        tok_parts.append(f"{DIM}{cache}c{RESET}")
    parts.append(' '.join(tok_parts))

# Session cost (USD) — shown on both API and subscription plans
cost = (data.get('cost') or {}).get('total_cost_usd')
if cost is not None:
    try:
        cost_f = float(cost)
        cost_color = RED if cost_f >= 20 else YELLOW if cost_f >= 5 else GREEN
        parts.append(f"{cost_color}${cost_f:.4f}{RESET}")
    except (TypeError, ValueError):
        pass

sep = f"{DIM} | {RESET}"
print(sep.join(parts))

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/plain-python-bar-5fd2e490.svg)](https://statuslin.es/c/plain-python-bar-5fd2e490?utm_source=readme-badge)

Or show the preview card:

Preview on statuslin.es
[![Preview on statuslin.es](https://statuslin.es/og/c/plain-python-bar-5fd2e490.png)](https://statuslin.es/c/plain-python-bar-5fd2e490?utm_source=readme-badge)

More status lines

  • 245 installs
╭─ CONTEXT ────────────────────────────────────────────╮ │ ████▊░░░░░░░░░░░░░░░░░ 22% of 200K · GOOD │ ├─ STATS ──────────────────────────────────────────────┤ │ ↓ 44.0K ↑ 1.4K │ $0.41 │ ⏱ 10m 12s │ +128/-34 │ ├─ REPO ───────────────────────────────────────────────┤ │ ◆ Opus 4.8 · main · 16:21 │ ╰──────────────────────────────────────────────────────╯
  • 83 installs
████▊░░░░░░░░░░░░░░░░░ 22% of 200K · GOOD │ ↓ 44.0K ↑ 1.4K │ $0.41 │ ⏱ 10m 12s │ +128/-34 │ 5h 26% ↻2h06m │ 7d 7% ↻2d0h │ ◆ Opus 5.5 · main · 03:53
  • 4 installs
◆ Opus 5.5 │ Effort: high │ cwd: ~ / app │ ⎇ main (+128,-34) │ MCP: 0 │ Context: [▰▰▱▱▱▱▱▱▱▱] 44k/200k (22%) │ ↓ 44.0K ↑ 1.4K ⛁ 2.0K (4%) │ $0.41 │ ⏱ 10m 12s
  • 4 installs
◆ Opus 4.8 ▏ ctx ▓▓░░░░░░░░ 22% ▏ high ▏ 10m main ▏ week ▓░░░░░░░░░ 7% ▏ 2d0h ▏ $0.41 ▏ +128/-34
  • 110 installs
Opus 4.8 [high] ~/app main 16:20:55 | ⛁ ██░░░░░░░░ 22% | 5h ●◔○○○ 26% ↻2h7m | 7d ◔○○○○○○ 7% ↻2d1h │ $0.41 ⏱ 10m
Opus 4.8 │ main │ app │ ▓▓░░░░░░░░ 44k/200k │ $0.41

Related mods

Token Weather Usage in Claude Desktop

One line above the prompt: context tokens with their weather, a bar per recent prompt, your 5-hour and 7-day limits against the time elapsed, the prompt cache with its time left, the session cost with the last prompt's share in dollars and in points of the 5-hour limit, the subagents running, and a one-click pill for the GOs Claude proposes. Labels in English, French or Russian. After Token Weather (Anthropic, Apache-2.0) and the ideas of usage-meter (HolyGrail) and prompt-cache-control (Daniel San).

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