Skip to main content

Real-time Claude Code cost dashboard — know exactly what you're spending

Project description

TokenWatch

Real-time Claude Code cost dashboard. Know exactly what you're spending — per session, per project, per day.

No proxy. No SDK wrapping. No API key required. Reads Claude Code's local session logs directly.


Install

pip install tokenwatch

Run

tokenwatch

Opens http://localhost:7842 automatically. That's it.

Commands

tokenwatch                   # start dashboard + open browser
tokenwatch start             # same as above
tokenwatch status            # print today's cost in terminal
tokenwatch export            # export 30 days to CSV
tokenwatch export --format json --days 90
tokenwatch seed              # generate demo data (no real logs needed)
tokenwatch seed --clean      # remove demo data
tokenwatch config            # show current settings

Options

tokenwatch --budget 20       # set $20/day budget
tokenwatch --port 8080       # different port
tokenwatch --no-browser      # don't open browser

Features

  • Live cost meter — updates in real time as Claude Code responds
  • Daily budget bar — turns orange at 80%, red at 100%
  • Desktop notifications — alerts at configurable thresholds (macOS, Linux)
  • Session drill-down — click any session to see per-message cost breakdown
  • Project breakdown — doughnut chart showing cost by project
  • CSV/JSON export — one-click download
  • Live pricing — fetched from Anthropic on startup, cached locally
  • Weekly email digest — optional (requires RESEND_API_KEY)
  • Auto-start on login — run bash install_autostart.sh once (macOS)

Configuration

Settings live in ~/.claude/tokenwatch_config.json. Edit directly or use the ⚙ button in the dashboard.

Key Default Description
daily_budget 10.00 Daily spend limit (USD)
alert_at_pct [80, 100] Notification thresholds
history_days 30 Days of history to show
port 7842 Server port
open_browser true Auto-open on start
digest_email "" Weekly email (needs RESEND_API_KEY)

Weekly digest email

export RESEND_API_KEY=re_...
tokenwatch  # set digest_email in Settings

Auto-start on macOS login

bash install_autostart.sh

How it works

Claude Code writes JSONL session logs to ~/.claude/projects/<project>/<session>.jsonl. TokenWatch watches that directory with OS-native file events (FSEvents on macOS, inotify on Linux), reads new entries within 300ms, and streams cost updates to the dashboard via Server-Sent Events.

Costs = token counts × live Anthropic prices. Cache tokens are priced correctly (10× cheaper than input).

Publishing to PyPI

# Tag a release
git tag v0.2.0 && git push --tags
# GitHub Actions auto-publishes via trusted publishing

Or manually:

make publish

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

tokenwatch-0.2.2.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

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

tokenwatch-0.2.2-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

Details for the file tokenwatch-0.2.2.tar.gz.

File metadata

  • Download URL: tokenwatch-0.2.2.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for tokenwatch-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a9fedad0c02d17b92cc127cdd2160811070e94054fa01c4e6b894bc95b4f320c
MD5 ee7f7810161db6f51866cd00e5d6cf0c
BLAKE2b-256 038a6c7a1b94963fe56f8629cf2ce09c5b7582d915772be26602ee1b9275d516

See more details on using hashes here.

File details

Details for the file tokenwatch-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: tokenwatch-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 38.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for tokenwatch-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3066fcd2f973a152d3504f666a8999a5dab44fd4592bea0a0406e3e3fd5391f8
MD5 257c41496075352e8719a6600cd2d1ae
BLAKE2b-256 891e43bb8159c9f93290ff6ba4b5bbd639817f719c3b1d428f8b770558e2d5a3

See more details on using hashes here.

Supported by

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