Skip to main content

claude-top

Claude Top screenshot

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.json is present with a valid OAuth token, claude-top fetches 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 files
  • q: Quit

How data is calculated

  • Scans all JSONL events in ~/.claude/projects recursively.
  • Counts each assistant event as one request.
  • Aggregates token fields from each assistant message usage payload:
    • input_tokens
    • output_tokens
    • cache_creation_input_tokens
    • cache_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:

  1. Claude Code has been used on this machine.
  2. ~/.claude/projects exists and contains .jsonl files.

Tier/reset countdown is missing

Tier and reset countdown information depends on OAuth metadata. If unavailable:

  • ensure ~/.claude/.credentials.json exists,
  • 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_top-0.2.0.tar.gz (151.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_top-0.2.0-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file claude_top-0.2.0.tar.gz.

File metadata

  • Download URL: claude_top-0.2.0.tar.gz
  • Upload date:
  • Size: 151.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claude_top-0.2.0.tar.gz
Algorithm Hash digest
SHA256 22d211385fb654b7c54a6f44d460db2f94bfa85d3bbdca0cb6327b8758d45e5c
MD5 8d901cb27af261e6f98f8a664a013de0
BLAKE2b-256 5e4175c1622632c26bd6234d07fe627add7f6cfdc2c2702c19c1f534cc72162e

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_top-0.2.0.tar.gz:

Publisher: publish.yml on xpodev/claude-top

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_top-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: claude_top-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claude_top-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc5c89dd08ecf2109ea3fbdabc4d0391f47c71cd517de972c6cf7b5ff1380893
MD5 1fc03956a690ce4345c924e1df9858a6
BLAKE2b-256 594a2abc36471c7c86a7502265860ceda0cf4a4da600b461117aec0083abb196

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_top-0.2.0-py3-none-any.whl:

Publisher: publish.yml on xpodev/claude-top

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page