Claude Code cost tracker — scans JSONL logs and reports token usage + estimated cost
Project description
cctrack
A lightweight CLI tool that scans Claude Code JSONL logs and reports token usage and estimated cost. Zero dependencies, runs anywhere Python 3.10+ is available.
Install
# Run directly (no install needed)
uvx cctrack
# Or install globally
uv tool install cctrack
Usage
# Scan local logs and print report
cctrack
# Last 7 days only
cctrack --days 7
# Aggregate with remote machines via SSH
cctrack --remote dgx macbook-air
# Custom log directories
cctrack --dirs ~/.claude/projects ~/.sandy/sandboxes
Example output
cctrack — Claude Code Cost Report
══════════════════════════════════
April 2026 — month to date (day 1, 1 active)
───────────────────────────────────────
Input tokens: 23,381
Output tokens: 199,069
Cache read: 30,862,977
Cache write: 1,051,023
Total tokens: 32,136,450
Total cost: $25.85
Avg/day: $25.85
Projected/mo: $775.50 (based on 1-day avg)
Daily breakdown:
Date Input Output Cache R Cache W Cost
──────────── ──────────── ──────────── ──────────── ──────────── ──────────
2026-04-01 23,381 199,069 30,862,977 1,051,023 $ 25.85
What it does
- Walks
~/.claude/projects/and~/.sandy/sandboxes/for JSONL log files - Parses
assistantevents with token usage - Deduplicates by
requestId(last event wins, matching Claude Code's semantics) - Calculates cost using Anthropic's published rates per model
- Prints daily breakdown with input/output/cache token splits and monthly summaries
Remote aggregation
With --remote, cctrack SSHs to each host (one call per host) and streams back all JSONL content for local parsing. Requires SSH key auth.
# Aggregate this machine + DGX server + laptop
cctrack --remote dgx macbook-air
Rate card
Prices per million tokens, from Anthropic's pricing page:
| Model | Input | Output | Cache Read | Cache Write |
|---|---|---|---|---|
| Opus 4.7 / 4.6 / 4.5 | $5.00 | $25.00 | $0.50 | $6.25 |
| Opus 4 / 4.1 | $15.00 | $75.00 | $1.50 | $18.75 |
| Sonnet 4.x / 3.7 | $3.00 | $15.00 | $0.30 | $3.75 |
| Haiku 4.x | $1.00 | $5.00 | $0.10 | $1.25 |
| Haiku 3.5 | $0.80 | $4.00 | $0.08 | $1.00 |
| Haiku 3 | $0.25 | $1.25 | $0.03 | $0.30 |
Unknown models fall back to Sonnet rates.
Origins
This is a Python rewrite of the Go-based cctrack dashboard. The Go version provides a full web dashboard with real-time updates, session explorer, and project breakdown. This Python version strips it down to the essentials: a single command that parses logs and prints a cost report. The JSONL parsing logic, deduplication strategy, and rate card are ported directly from the Go implementation.
License
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 cctrack-0.2.0.tar.gz.
File metadata
- Download URL: cctrack-0.2.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b825205f067ff4616baaab9b0089e3f7b5ce5b2797a7b23e544683252b1efb6
|
|
| MD5 |
f6ffa3966919f094c2e9696f989690c2
|
|
| BLAKE2b-256 |
e2ebb6b2112959b4aeaaf76fe87822f33464870043fbdaeb626f312c1d82cc7b
|
Provenance
The following attestation bundles were made for cctrack-0.2.0.tar.gz:
Publisher:
publish.yml on rappdw/cctrack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cctrack-0.2.0.tar.gz -
Subject digest:
6b825205f067ff4616baaab9b0089e3f7b5ce5b2797a7b23e544683252b1efb6 - Sigstore transparency entry: 1328401632
- Sigstore integration time:
-
Permalink:
rappdw/cctrack@f7698c672aa10ece791723498cfa77bd81b93562 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/rappdw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f7698c672aa10ece791723498cfa77bd81b93562 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cctrack-0.2.0-py3-none-any.whl.
File metadata
- Download URL: cctrack-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.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 |
7f84d200475750ab795bd8ea13579cde3698a3ea78ddfdeef0d2cd4645d801a7
|
|
| MD5 |
995168f0cab26d6bd414a8559af3c0f7
|
|
| BLAKE2b-256 |
867dff0047b709dd2c617f3c33631998338d99637f35dc82aa801fa3c85431b2
|
Provenance
The following attestation bundles were made for cctrack-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on rappdw/cctrack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cctrack-0.2.0-py3-none-any.whl -
Subject digest:
7f84d200475750ab795bd8ea13579cde3698a3ea78ddfdeef0d2cd4645d801a7 - Sigstore transparency entry: 1328401662
- Sigstore integration time:
-
Permalink:
rappdw/cctrack@f7698c672aa10ece791723498cfa77bd81b93562 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/rappdw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f7698c672aa10ece791723498cfa77bd81b93562 -
Trigger Event:
release
-
Statement type: