Claude Code transcript cost analyzer
Project description
cc-cost
A tiny Claude Code cost analyzer. Parses Claude Code session transcript JSONL files and reports per-session cost, prompt-cache hit rate, tool-call distribution, and the top expensive turns.
Knowing your cache hit rate is load-bearing for cost — a session at 91% hit rate costs ~10× less than the same work at 0%.
Install
curl -O https://raw.githubusercontent.com/lob-labs/cc-cost/main/cc-cost.py
chmod +x cc-cost.py
No dependencies beyond Python 3.9+.
Use
# Scan all sessions under ~/.claude/projects
./cc-cost.py
# A specific transcript
./cc-cost.py ~/.claude/projects/-home-foo/<id>.jsonl
# Single project
./cc-cost.py --project -home-foo
# JSON output (for automation)
./cc-cost.py --json
# Get specific cost-optimization recommendations
./cc-cost.py --diagnose <transcript.jsonl>
# Show only the top 5 most expensive sessions
./cc-cost.py --top 5
Sample output
=== <session>.jsonl ===
model: claude-opus-4-7
turns: 62
input tokens: 232
output tokens: 10,016
cache write: 216,089
cache read: 2,179,125
cache hit rate: 91.0% (higher = cheaper)
total cost USD: $ 8.0750
tool calls:
Bash 40
Write 2
ToolSearch 1
top 5 expensive turns:
$ 0.6993 [...]
Why
When debugging "why was this session $40," the answer is almost always one of:
- Low cache hit rate (long static context not marked
cache_control) - Many redundant tool calls (each one re-pays the prompt)
- Long-output explanations the model generated unprompted
This shows you which of those is biting you, fast.
Tip jar
If this saved you money, consider tipping:
- Venmo: @lobsterlabs
- USDC on Base / any EVM:
0xE0c311585d2000afF6b8020e30912Ac37ffe406a - USDC on Solana / SOL:
4a6YaVijdv79iXvXvXFu67kVBPFA6n8YSwYXt3ECj6ND
License
MIT.
Project details
Release history Release notifications | RSS feed
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 cc_cost-1.1.0.tar.gz.
File metadata
- Download URL: cc_cost-1.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
054c1f2dd37d72d76f8d3b44a98d56e62c3f27ba0eaa2491b438063963f871c8
|
|
| MD5 |
2bfce8ea4d1e9e22f48548c66a8fb577
|
|
| BLAKE2b-256 |
21345c79da99ce31c19216d1df0a5d29dc4df0d68537f6af85aa2fdf71c67754
|
File details
Details for the file cc_cost-1.1.0-py3-none-any.whl.
File metadata
- Download URL: cc_cost-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fe7d0e18f56146d6f01ab4a6bc1d691820345d5ac1e78c23a9a8aeb42b84e23
|
|
| MD5 |
a2fb31f8670426693afd60e22b9700de
|
|
| BLAKE2b-256 |
fe553ea9786012b4f805d1aa58ede9deb3652dd237631c23868a72d56bb04680
|