claude-top
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).
What it shows
- 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
Requirements
- 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-topfetches utilization percentages from the Anthropic OAuth usage API on a configurable interval (default: once per minute). Local session files are read more frequently to track new tokens without hitting rate limits.
Installation
Run without install (uvx)
uvx claude-top
Install globally (uv)
uv tool install claude-top
Install with pip
pip install claude-top
From source
git clone https://github.com/xpodev/claude-top.git
cd claude-top
uv pip install -e .
Usage
# 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
# Fetch API utilization every 5 minutes instead of the default 1
claude-top --api-refresh 5
CLI options
--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: How often to read local session files, in seconds (default: 1).--api-refresh MINUTES: How often to fetch utilization percentages from the Anthropic API, in minutes (default: 1). Increase this to reduce API calls.
TUI keybindings
r: Refresh — fetches fresh API data and re-reads local session filesq: Quit
How data is calculated
- 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.
Troubleshooting
"No Claude Code session data found"
claude-top only reads local Claude session files. Make sure:
- Claude Code has been used on this machine.
~/.claude/projectsexists and contains.jsonlfiles.
Tier/reset countdown is missing
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.
Utilization percentages not updating
Usage bars reflect the last API response. By default the API is polled once per minute. Press r to force an immediate refresh, or lower --api-refresh (e.g. --api-refresh 1).
Development
# 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 -q
License
MIT
Metadata
Release files for claude-top 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| claude_top-0.3.0.tar.gz | 155.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| claude_top-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 182.0 kB
Release files / claude_top-0.3.0.tar.gz
| Download URL | claude_top-0.3.0.tar.gz |
|---|---|
| Size | 155.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2e47b7297c3db9c9f5736045e5d0845c77b4497b28008b5a5f1f4c6686fefe0
|
|
BLAKE2b-256 checksum How to use checksums |
e89e17250cb65b1be0f5b437a398bd0ce8506c9fdcc5cc0d620fa6ef00114afc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency logRelease files / claude_top-0.3.0-py3-none-any.whl
| Download URL | claude_top-0.3.0-py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87825b1db300d0ff32a313eb20f61c3c1b31f710eb892c62b811d5ae7775f600
|
|
BLAKE2b-256 checksum How to use checksums |
a8ff10a24ed42f63efde5503f4084d2c2126a44e230c1e806c6dba20243623ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency log