Skip to main content

Track and reduce your Claude/Anthropic API costs from the terminal

Project description

tokenwise

See exactly where your Claude tokens go — and stop wasting them.

CI CodeQL OpenSSF Scorecard PyPI Python License: MIT

tokenwise dashboard demo


Security

tokenwise makes zero network calls. It only reads Claude Code's local logs. Audit it in 5 minutes.

This tool reads sensitive data (your Claude session logs). Here is exactly what it does and does not do:

Guarantee How it's enforced
No network calls Runtime assertion checks sys.modules at startup; grep CI check
Read-only on ~/.claude/ Only open(path, 'r') touches that directory; unit tested
No eval / exec / pickle / subprocess Grep CI check on every push
No telemetry or "phone home" See above — no network stack imported
Cache stored with 0o700 / 0o600 perms Enforced in storage.py
JSON-only serialization No pickle, no exec of user-controlled data

Audit it yourself — paste these into your terminal after cloning:

# Should return nothing (no network imports)
grep -rE "import (requests|urllib|httpx|socket|http\.client)" src/

# Should return nothing (no code execution)
grep -rE "\b(eval|exec|pickle|subprocess|os\.system)\b" src/

# Should return nothing (no writes to the Claude log directory)
grep -rE 'open\(.*["\'][wa+]' src/

# Confirm all file reads go through our safe_path() check
grep -rn "safe_path" src/tokenwise/

See THREAT_MODEL.md for the full analysis.


What is tokenwise?

tokenwise reads your local Claude Code logs (~/.claude/projects/) and gives you a beautiful terminal breakdown of exactly how many tokens you've burned — by project, session, and day — with cost estimates and waste warnings.

Zero cloud sync. Zero telemetry. Pure read-only.


Features

  • Live dashboard — real-time token + cost view across all projects
  • Daily / weekly reportstokenwise today, tokenwise week
  • Per-project drill-downtokenwise project <name>
  • Waste detectortokenwise waste flags sessions with huge context for tiny output
  • CSV exporttokenwise export --csv
  • Cache-aware cost — distinguishes input, output, cache-write, and cache-read pricing
  • Works offline, reads logs directly — no API key needed

Install

pip install tokenwise-cli

Or with pipx (recommended for CLI tools):

pipx install tokenwise-cli

Requirements

Python 3.10 or later is required. Check your version:

python3 --version

Development setup (for contributors):

git clone https://github.com/S0umith29/tokenwise.git
cd tokenwise
python3.13 -m venv .venv          # or python3.10 / 3.11 / 3.12
source .venv/bin/activate
pip install -e ".[dev]"
make verify                        # runs tests + all security checks

Quickstart

# Live dashboard (updates every 5 seconds)
tokenwise

# Today's usage
tokenwise today

# Last 7 days
tokenwise week

# Drill into a project
tokenwise project myapp

# Find wasteful sessions
tokenwise waste

# Export raw data
tokenwise export --csv > usage.csv

How it works

Claude Code writes JSONL logs to ~/.claude/projects/<project-slug>/<session-id>.jsonl. Each assistant message includes a usage object with input_tokens, output_tokens, cache_creation_input_tokens, and cache_read_input_tokens. tokenwise parses these, applies current Anthropic pricing, and aggregates the results.

Parsed data is cached in ~/.tokenwise/cache.json (permissions 0o600) so repeated runs are instant.


Contributing

See CONTRIBUTING.md.

Pricing data lives in src/tokenwise/pricing.py. If Anthropic updates their prices, PRs to update that file are very welcome.


License

MIT © Sowmith Kuppa

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

tokenwise_cli-0.1.1.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

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

tokenwise_cli-0.1.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file tokenwise_cli-0.1.1.tar.gz.

File metadata

  • Download URL: tokenwise_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for tokenwise_cli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6e69e9caaa96b9c0c456fd641217a7f8ec982fa2b933733dc1b5e2bae5d61366
MD5 a66dfae45035ab3bedf9d54da4dddeb8
BLAKE2b-256 0c46edcc106c3f1473a4c16c09688e3c8a689fa9c7d9b17ab04c5b760e51f3ba

See more details on using hashes here.

File details

Details for the file tokenwise_cli-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tokenwise_cli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for tokenwise_cli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38c164c3849e9d1037c549eae5ab4184badfc3793eebfad2e4bc4c744cd168b8
MD5 7867d231f194ab918c1e623ed7635a0b
BLAKE2b-256 f17c601eebdb2bdfb525e18de2724d7a2b44f7f98497aa5fe78b58551243f1ed

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