Back to context-stats

Getting started

Docs · Product/Service: context-stats

Requirements

Python 3.10 or newer. Claude Code; v2.1.153 or newer for the multi-line layout on narrow terminals. Optional: git for branch info, the gh CLI for the PR number.

Install

pip install context-stats
uv pip install context-stats

Configure

Wire the status line into Claude Code:

context-stats doctor --fix

Or add this to ~/.claude/settings.json by hand:

{ "statusLine": { "type": "command", "command": "claude-statusline" } }

Settings live in ~/.claude/statusline.conf as key=value lines, no spaces around =. The file is created with defaults on first run.

  • show_deltatokens used since the last refresh. Default true.
  • show_miModel Intelligence score. Default false.
  • show_costsession cost in USD. Default true.
  • show_effortreasoning effort next to the model. Default true.
  • show_pacmanzone icon next to the zone label. Default true.
  • show_prpull-request number for the current branch (needs gh). Default true.
  • show_sessionsession ID. Default true.
  • show_tpsgeneration throughput in tokens/s. Default false.
  • show_accountlogged-in Claude account email. Default false.
  • token_detailexact token counts (true) or abbreviated, like 64.0k (false). Default true.
  • autocompactset true when autocompact is on in Claude Code's /config. Default false.
  • color_<element>18 named colors or any #rrggbb hex, such as color_mi_score=#ff9e64.

First run

Restart Claude Code. On the next turn the status line shows, for example:

my-project | main [3] | 64,000 free (32.0%)·Code·ᗤ | MI:0.918 | +2,500 | $0.42 | Opus 4.6·high | abc-123

Commands

  • context-stats doctorcheck the install chain; exits non-zero on failure
  • context-stats doctor --fixwrite the statusLine block into settings.json, with a backup
  • context-stats sessionssessions active in the last 5 minutes; --minutes 30 widens the window
  • context-stats graphlive context-growth graph for the latest session
  • context-stats graph --type allevery graph: delta, cumulative, cache, mi, io, tps
  • context-stats graph -w 5 / --no-watchrefresh every 5 seconds / draw once and exit
  • context-stats <session_id> graphgraphs for a specific session
  • context-stats export --output report.mdMarkdown deep-dive of the latest session
  • context-stats report --since-days 30cost and cache report across all projects

Troubleshooting

  • Status line not appearing
    run context-stats doctor and apply the fix it prints.
  • context-stats: command not found
    add ~/.local/bin to PATH:
    echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
  • Configuration not taking effect
    remove spaces around = (show_delta=true), then restart Claude Code.
  • Delta always shows zero
    the first refresh sets a baseline; check the state file grows with
    wc -l ~/.claude/statusline/statusline.*.state

Uninstall

[proof needed — documented uninstall command], then remove the statusLine block from ~/.claude/settings.json.