A CLI + TUI utility for inspecting Claude Code usage from local session files.
claude-top reads your local Claude history (~/.claude/projects/**/*.jsonl), aggregates token/request metrics, and presents them in either:
- an interactive Textual dashboard (default),
- a Rich terminal table (
--no-ui), or - JSON (
--json).
- Total input/output tokens and request count
- Per-model usage breakdown
- Optional detailed stats (
--detailed):- cache reads/writes and hit rate
- average tokens per request
- estimated cost (informational)
- 7-day trend sparkline
- week-over-week comparison
- top projects by token usage
- Tier-aware usage bars and warnings (80%/90%) when tier metadata is available
- Python 3.9+
- Existing Claude Code data in
~/.claude/projects
Notes:
- No setup is required to read local usage files.
- If
~/.claude/.credentials.jsonis present with a valid OAuth token,claude-topalso tries to fetch usage window reset metadata from Anthropic OAuth usage API for better countdowns.
uvx claude-topuv tool install claude-toppip install claude-topgit clone https://github.com/xpodev/claude-top.git
cd claude-top
uv pip install -e .# Launch TUI (auto-refresh by default)
claude-top
# Print terminal table once and exit
claude-top --no-ui --once
# Print terminal table with refresh
claude-top --no-ui --watch 5
# Print JSON once and exit
claude-top --json
# Include detailed analytics
claude-top --detailed--once: Display once and exit.--no-ui: Use table output instead of the TUI.--json: Print JSON output and exit.--detailed: Include detailed analytics.--watch N: Refresh interval in seconds (default: 1 when not using--once).
r: Refresh nowq: Quit
- Scans all JSONL events in
~/.claude/projectsrecursively. - Counts each
assistantevent as one request. - Aggregates token fields from each assistant message usage payload:
input_tokensoutput_tokenscache_creation_input_tokenscache_read_input_tokens
- Derives project names from common event path/project fields.
- Builds last-7-day trend and week-over-week token comparison from timestamps.
claude-top only reads local Claude session files. Make sure:
- Claude Code has been used on this machine.
~/.claude/projectsexists and contains.jsonlfiles.
Tier and reset countdown information depends on OAuth metadata. If unavailable:
- ensure
~/.claude/.credentials.jsonexists, - ensure the OAuth token is valid,
- check network access to Anthropic API.
The tool still works with local usage data even if tier/reset metadata cannot be fetched.
# Clone repository
git clone https://github.com/xpodev/claude-top.git
cd claude-top
# Install with development dependencies
uv pip install -e ".[dev]"
# Run tests
uv run pytest -qMIT
