phuryn/claude-usage
Sobre
Um dashboard local para acompanhar o uso de tokens, os custos e o histórico de sessões do Claude Code. Assinantes dos planos Pro e Max recebem uma barra de progresso. Tenha uma visão completa.
Ferramentas de desenvolvimentoCrescimento medido de estrelas
- em 24 h
- +1
- em 7 dias
- +6
- em 15 dias
- +19
- em 1 mês
- +52
Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.
README.md
OriginalClaude Code Usage Dashboard
Pro and Max subscribers get a progress bar. This gives you the full picture.
claude-usage reads local usage logs from Claude Code and OpenAI Codex. See token counts, models, sessions, projects, and estimated API costs in the dashboard or terminal.
Usage data stays on the machine running the dashboard. The VS Code extension has an anonymous sidebar-opening event with an opt-out. Privacy and network requests.

Available as a web app (python cli.py dashboard) and as a VS Code extension.
Created by: The Product Compass Newsletter
What this tracks
Works with Claude Code API, Pro, and Max usage and with Codex usage on API and ChatGPT plans when local logs are available.
Captures usage from:
- Claude Code CLI (
claudecommand in terminal) - VS Code extension (Claude Code sidebar)
- Dispatched Code sessions (sessions routed through Claude Code)
- Codex CLI sessions written to the local rollout directory
Not captured:
- Cowork sessions — these run server-side and do not write local JSONL transcripts
Requirements
- Python 3.8+
- No third-party packages — uses only the standard library (
sqlite3,http.server,json,pathlib)
Anyone running Claude Code already has Python installed.
Quick Start
No pip install, no virtual environment, no build step.
macOS / Linux (Homebrew)
brew tap phuryn/claude-usage https://github.com/phuryn/claude-usage
brew install phuryn/claude-usage/claude-usage
claude-usage dashboard
Homebrew has disabled installing a formula from an arbitrary raw URL, so tap the repo first (thanks @adrianlungu for the working incantation in #46).
After install, the claude-usage command is on your PATH and accepts the same subcommands as python cli.py (scan, today, week, stats, dashboard).
Any OS (uv tool / pipx)
uv tool install git+https://github.com/phuryn/claude-usage
claude-usage dashboard
Installs the claude-usage command without a clone (works with pipx too: pipx install git+https://github.com/phuryn/claude-usage). The tool stays dependency-free — this only adds packaging metadata, no third-party runtime deps (#144).
macOS / Linux (clone)
git clone https://github.com/phuryn/claude-usage
cd claude-usage
python3 cli.py dashboard
Windows
git clone https://github.com/phuryn/claude-usage
cd claude-usage
python cli.py dashboard
Docker
git clone https://github.com/phuryn/claude-usage
cd claude-usage
bash scripts/run-docker.sh
The dashboard is available at http://127.0.0.1:9898 on the Docker host.
The script builds the image, then runs the container with:
~/.claudemounted read-only — the container can read your transcripts but cannot modify them- A named Docker volume (
claude-usage-data) for the SQLite database — persisted across restarts, isolated from your home directory - Container port
8080published on the host's loopback interface
The image sets CLAUDE_USAGE_DOCKER=1 and binds to 0.0.0.0 inside the container. This makes the dashboard require a loopback Host and the dashboard's own origin for browser rescans. When running the image directly, publish the port with -p 127.0.0.1:9898:8080. The image applies the same checks to both paths.
The launcher reads Claude Code logs from its existing mount. To include Codex when running the image directly, mount only the host's rollout directory read-only with --mount type=bind,source="$HOME/.codex/sessions",target=/codex/sessions,readonly -e CODEX_HOME=/codex. If you use a custom Codex home, use its sessions directory as the source.
Usage
On macOS/Linux, use
python3instead ofpythonin all commands below. If you installed via Homebrew, replacepython cli.pywithclaude-usage.
# Scan JSONL files and populate the database (~/.claude/usage.db)
python cli.py scan
# Show today's usage summary by model (in terminal)
python cli.py today
# Show the last 7 days (per-day breakdown + by-model totals)
python cli.py week
# Show all-time statistics (in terminal)
python cli.py stats
# Scan + open browser dashboard at http://127.0.0.1:8080
python cli.py dashboard
# Custom host and port
python cli.py dashboard --host 0.0.0.0 --port 9000
# Environment variables are also supported
HOST=0.0.0.0 PORT=9000 python cli.py dashboard
# Scan a custom projects directory
python cli.py scan --projects-dir /path/to/transcripts
The scanner tracks each file's path, size, modification time and completed lines. It skips unchanged files and picks up appended usage on a rescan.
By default, the scanner checks ~/.claude/projects/, the Xcode Claude integration directory (~/Library/Developer/Xcode/CodingAssistant/ClaudeAgentConfig/projects/), and ~/.codex/sessions/ for rollout-*.jsonl. Set CODEX_HOME to the Codex home directory that contains sessions. Missing directories are skipped. With --projects-dir, the scanner reads only Claude Code transcripts in the specified directory. This also applies to dashboard startup and Rescan.
How it works
Claude Code writes one JSONL file per session to ~/.claude/projects/. Each line is a JSON record; assistant-type records contain:
message.usage.input_tokens— uncached prompt tokensmessage.usage.output_tokens— generated tokensmessage.usage.cache_creation_input_tokens— tokens written to prompt cachemessage.usage.cache_read_input_tokens— tokens served from prompt cachemessage.model— the model used (e.g.claude-sonnet-4-6)
For Codex, scanner.py uses each response's token_usage_record and the model from turn_context. It subtracts cache reads and writes from reported input so each token appears in one bucket. When a rollout has only older token_count events, it uses the last-request counts when the cumulative counts advance consistently with one request. In a file containing both formats, response records take precedence, so an older prefix of a resumed rollout may be omitted. Archived rollouts and Codex plan limits are outside the scan.
Both tools share the SQLite database at ~/.claude/usage.db. Existing history is migrated as Claude Code usage. When the dashboard has Codex data, the Tool filter narrows the existing date and model selections. Session, project and branch tables show the tool. The Codex view labels subagent dispatches, 1-hour cache writes and Anthropic peak hours as Claude Code information.
dashboard.py serves a single-page dashboard at http://127.0.0.1:8080 by default, with Chart.js loaded from a CDN and checked by the browser for integrity. While the selected range includes today, the dashboard incrementally scans for new usage and refreshes the view every 30 seconds. Model and date filters have bookmarkable URLs. A sticky section nav jumps between sections, and every chart/table can be collapsed (remembered across reloads). The bind address and port can be configured with the --host and --port flags, or the HOST and PORT environment variables (defaults: localhost, 8080).
Usage days, dashboard ranges such as Today, and the hourly chart's Local mode use the time zone where claude-usage runs. With Docker, the container's time zone decides when a new day starts. The same server calendar applies when viewing the dashboard from another device or through VS Code Remote.
Cost estimates
Cost estimates use the December 2026 standard API rates. Anthropic pricing · OpenAI pricing
Claude Code prices use known Claude models and their family names. Codex prices use listed OpenAI models and dated snapshots of those same models. Usage with no known price shows n/a and contributes zero to estimated cost.
| Model | Input | Output | Cache write (5 min) | Cache write (1 h) | Cache read |
|---|---|---|---|---|---|
| claude-fable-5-2, claude-mythos-5-2 | $8.00/MTok | $40.00/MTok | $10.00/MTok | $16.00/MTok | $0.20/MTok |
| claude-fable-5-1, claude-mythos-5-1 | $10.00/MTok | $50.00/MTok | $12.50/MTok | $20.00/MTok | $0.25/MTok |
| claude-fable-5, claude-mythos-5 | $10.00/MTok | $50.00/MTok | $12.50/MTok | $20.00/MTok | $1.00/MTok |
| claude-opus-5-5 | $4.00/MTok | $20.00/MTok | $5.00/MTok | $8.00/MTok | $0.20/MTok |
| claude-opus-5, claude-opus-4-8 … 4-5 | $5.00/MTok | $25.00/MTok | $6.25/MTok | $10.00/MTok | $0.50/MTok |
| claude-sonnet-5-5 | $2.00/MTok | $10.00/MTok | $2.50/MTok | $4.00/MTok | $0.10/MTok |
| claude-sonnet-5 | $2.00/MTok | $10.00/MTok | $2.50/MTok | $4.00/MTok | $0.20/MTok |
| claude-sonnet-4-7 … 4-5 | $3.00/MTok | $15.00/MTok | $3.75/MTok | $6.00/MTok | $0.30/MTok |
| claude-haiku-5-5 (prompts up to 100K tokens) | $0.10/MTok | $0.50/MTok | $0.125/MTok | $0.20/MTok | $0.01/MTok |
| claude-haiku-4-7 … 4-5 | $1.00/MTok | $5.00/MTok | $1.25/MTok | $2.00/MTok | $0.10/MTok |
Claude Code writes most of its prompt cache with the 1-hour lifetime. The scanner reads the split from each response and prices each lifetime separately. Haiku 5.5 prompts over 100K are estimated using the lower rate and can be underestimated.
For Codex, reasoning tokens bill at the output rate and are already included in output_tokens. Cache writes use the 30-minute rate when available because rollouts do not identify their lifetime. The sampled responses reported zero cache writes. When a model has long-context rates, the entire request uses that tier if its reported input exceeds 272,000 tokens, including cached input and cache writes.
These estimates show what the same usage would cost at standard API rates. Claude Pro/Max and ChatGPT plan charges follow the terms of your subscription.
VS Code extension
If you'd rather see the dashboard inside your editor, the same UI is available as a VS Code extension. Same data, same charts, embedded as an activity-bar sidebar.
Install from the VS Code Marketplace →

The Python sources are bundled inside the .vsix, so the only end-user requirement is Python 3.8+ on your PATH. After install, click the gauge icon in the activity bar — the server spawns automatically and the dashboard renders in the sidebar.
See vscode-extension/README.md for settings, commands, discovery order, and local-install instructions.
Files
| File | Purpose |
|---|---|
scanner.py |
Parses JSONL transcripts, writes to ~/.claude/usage.db |
dashboard.py |
HTTP server + single-page HTML/JS dashboard |
cli.py |
scan, today, week, stats, dashboard commands |
Formula/claude-usage.rb |
Homebrew formula — install with brew tap phuryn/claude-usage then brew install phuryn/claude-usage/claude-usage |
vscode-extension/ |
VS Code extension — embeds the dashboard inside VS Code |
Dockerfile |
Container image definition |
scripts/run-docker.sh |
Build and run the dashboard in Docker with a read-only ~/.claude mount |
Explore projetos relacionados
Carregando…