CLI + TUI for viewing Claude Code usage statistics from local session files
Project description
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-topalso tries to fetch usage window reset metadata from Anthropic OAuth usage API for better countdowns.
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
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: Refresh interval in seconds (default: 1 when not using--once).
TUI keybindings
r: Refresh nowq: 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.
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_top-0.1.0.tar.gz.
File metadata
- Download URL: claude_top-0.1.0.tar.gz
- Upload date:
- Size: 130.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e95c0454a403ee581471a4d5c8d1facaf912a1667edce9ddd392df87d13c2f4
|
|
| MD5 |
677b7a5865dcd5b2d07278d5d1e36804
|
|
| BLAKE2b-256 |
b660f5759e4377b4de62059126d0c14fa22ee56dc52fda6410e1584c4346062b
|
Provenance
The following attestation bundles were made for claude_top-0.1.0.tar.gz:
Publisher:
publish.yml on xpodev/claude-top
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_top-0.1.0.tar.gz -
Subject digest:
4e95c0454a403ee581471a4d5c8d1facaf912a1667edce9ddd392df87d13c2f4 - Sigstore transparency entry: 1710169115
- Sigstore integration time:
-
Permalink:
xpodev/claude-top@6984c5a7814734cb0bb5749e2848a1ddbafc65eb -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/xpodev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6984c5a7814734cb0bb5749e2848a1ddbafc65eb -
Trigger Event:
release
-
Statement type:
File details
Details for the file claude_top-0.1.0-py3-none-any.whl.
File metadata
- Download URL: claude_top-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
034f2ea5693d01b7e3989bd567089b98dbfa7156b9cfca5feaccf24fff163f3a
|
|
| MD5 |
f76371e5a5b6994f2caa0b57e5f49ace
|
|
| BLAKE2b-256 |
42c4e8674cf77d0fd57ee833b6881b1092c454ea271f02b1845751725efa6bc5
|
Provenance
The following attestation bundles were made for claude_top-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on xpodev/claude-top
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_top-0.1.0-py3-none-any.whl -
Subject digest:
034f2ea5693d01b7e3989bd567089b98dbfa7156b9cfca5feaccf24fff163f3a - Sigstore transparency entry: 1710169139
- Sigstore integration time:
-
Permalink:
xpodev/claude-top@6984c5a7814734cb0bb5749e2848a1ddbafc65eb -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/xpodev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6984c5a7814734cb0bb5749e2848a1ddbafc65eb -
Trigger Event:
release
-
Statement type: