agentleFS
vklapvklap/claude-status-line/CLAUDE.md

claude-status-line

CLAUDE.md0 starsChanged 6 months agoMITView on GitHub

A Claude Code plugin that installs a single-line status line showing live Claude token usage: a color-coded context-window progress bar, session cost, Pro/Max rate-limit usage, and (optional) org-wide Anthropic API usage. Pure Python 3, standard library only — no third-party dependencies. Two Claude Code facts drive the whole design: 1. A plugin cannot configure the main statusLine. A plugin's settings.json only honors agent and subagentStatusLine; a statusLine key there is silently ignored. So instead of declaring the status line, the…

The file

Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What this is

A Claude Code plugin that installs a single-line status line showing live Claude token usage: a color-coded context-window progress bar, session cost, Pro/Max rate-limit usage, and (optional) org-wide Anthropic API usage. Pure Python 3, standard library only — no third-party dependencies.

Architecture and the constraints that shape it

Two Claude Code facts drive the whole design:

  1. A plugin cannot configure the main statusLine. A plugin's settings.json only honors agent and subagentStatusLine; a statusLine key there is silently ignored. So instead of declaring the status line, the plugin ships the renderer plus code that writes the statusLine entry into the user's ~/.claude/settings.json. scripts/install.py does the actual work, triggered two ways: explicitly via skills/install/SKILL.md (/claude-status-line:install), or automatically via a SessionStart hook (hooks/hooks.json → scripts/auto_install.py) so merely enabling the plugin sets the bar up on the next session. The hook is conservative: it installs only when no statusLine is set, refreshes the runtime copy when the statusLine is already this plugin's, and never touches a foreign one. It is silent (SessionStart stdout is injected into context) and always exits 0.
  2. ${CLAUDE_PLUGIN_ROOT} is not substituted inside the user's settings.json statusLine command, and the plugin's install path changes on every update (old dirs are cleaned ~7 days later). So the installer copies the runtime to a stable ~/.claude/claude-status-line/ and points settings there — the copy is intentional, not a bug. Plugin updates propagate on the next session because the SessionStart hook re-copies the runtime when the bar is already ours; re-running /claude-status-line:install forces the same refresh immediately.

Data flow at render time: Claude Code pipes session JSON on stdin to statusline.py after each assistant message / /compact / mode change. context_window.*, cost.*, and rate_limits.* come from that JSON (free, live). Org-wide usage is not in the JSON — it comes from the Admin API, so statusline.py reads a cache (~/.claude/claude-status-line/usage-cache.json) and, when stale, spawns usage_fetch.py detached (throttled by a lock file) so renders never block on the network.

Layout

  • statusline/statusline.py — renderer (stdin JSON → one line). Per-segment try/except, always exits 0. This is the file copied to ~/.claude/ and run as the status line.
  • statusline/usage_fetch.py — background Admin Usage API fetcher (stdlib urllib), writes the cache atomically.
  • scripts/install.py / uninstall.py — settings + runtime management.
  • scripts/auto_install.py — SessionStart hook entry point; reuses install.py's copy_runtime() / patch_settings() to install-if-absent.
  • hooks/hooks.json — registers auto_install.py on SessionStart.
  • skills/{install,uninstall,config}/SKILL.md — user-invoked entry points (disable-model-invocation: true); reference scripts via ${CLAUDE_PLUGIN_ROOT}.
  • config.example.json — seeded to ~/.claude/claude-status-line/config.json on install (never overwritten if present).
  • .claude-plugin/plugin.json + marketplace.json — manifest + makes the repo installable as a marketplace (source: "./", plugin at repo root).

Conventions when editing

  • No third-party imports in any runtime script. Portability is the point.
  • statusline.py must never crash or hang — keep segments cheap, swallow errors per segment, and exit 0.
  • The user's config.json is sacred: the installer copies the example only when it is absent; never clobber it.
  • The status line is a single line; keep new segments compact and toggleable via config.json.

Context window fields

used_percentage is input-only (input_tokens + cache_creation_input_tokens + cache_read_input_tokens). If you compute the percentage manually from current_usage, use the same input-only formula to match. Both context_window.used_percentage and current_usage can be null early in a session and right after /compact — always provide fallbacks.

Testing

# Render at different usage levels (watch the bar change color):
echo '{"model":{"display_name":"Opus"},"context_window":{"used_percentage":70,"total_input_tokens":140000,"context_window_size":200000},"cost":{"total_cost_usd":0.42},"rate_limits":{"five_hour":{"used_percentage":23},"seven_day":{"used_percentage":41}},"session_id":"t"}' | python3 statusline/statusline.py

echo '{}' | python3 statusline/statusline.py   # must not crash; prints a fallback

claude plugin validate .                        # validate manifest + marketplace
claude --plugin-dir .                           # load locally, then /claude-status-line:install

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.