What your Claude Code sessions really cost
The job is reading Claude Code's local transcript files and turning them into tokens and dollars per session. Two tools claim to do it. In November 2026 I ran both on copies of my own transcripts and checked one session by hand. Neither gave a dollar figure I could use, and the reason is in the file format, so it will catch any script you write yourself too.
Tools, in the order I tried them
- cc-cost (lob-labs/cc-cost, version 1.1.0, tested 6 November 2026). One 330-line Python script with no dependencies. It only reads.
- claudia, now called opcode (getAsterisk/claudia, tested 6 November 2026). A Tauri desktop app. I didn't build it. I rewrote its token-reading code line for line in Python and pointed that at copies of four transcripts.
- My own price table, to recompute the same sessions.
# one session, with its written advice
python3 -I repo/cc_cost.py SESSION_FILE.jsonl --diagnose
# a whole project folder; the = matters, see below
python3 -I repo/cc_cost.py --json --project=-PROJECT_FOLDER_NAME
The trap: one message, several lines
Claude Code writes one transcript line per content block (thinking, text, each tool call), and every one of those lines carries the same message id and the same usage numbers. Add up every line and you count the same tokens several times. Across the folder I tested, that came to about 3.4 times.
One Sonnet session made it concrete: 83 usage lines, 36 real messages.
- cc-cost printed 96,988 output tokens, 8,327,772 cache-read tokens and $30.45.
- With repeats removed, the same session has 39,431 output and 3,580,941 cache-read tokens.
- Priced at current Sonnet 5 rates, that is $1.63. cc-cost was 18.6 times too high. Two other sessions came out 14 and 20 times too high.
What each tool got right and wrong
cc-cost adds every line, so it carries the repeat error. Its price table has four entries, Opus 4.6 and 4.7, Sonnet 4.6 and Haiku 4.5, and anything it doesn't recognise is priced as old Opus ($15 in, $75 out per million). Every 5.x model I use falls through to that price. Its tests use tidy fake transcripts with one line per message, so the real file shape is never tested.
claudia handles the repeats. It skips a line once it has seen the same message id : requestId pair, across all files. On that Sonnet session it reported 36 messages and 39,431 output tokens, which matches my count. But it priced all four files at $0.00, because its table only knows model names containing opus-4 or sonnet-4 and prices anything else at zero on purpose. Its token counts are right. The dollars need a table someone keeps current.
Both ignore the entrypoint field that says whether a transcript came from a person in an editor or from a headless claude -p run. A project folder full of scripted runs shows up as a pile of tiny sessions mixed in with real ones.
What else broke
- cc-cost's README example
--project -home-foostops with "expected one argument", because Claude Code's folder names start with a dash and Python's argument parser reads that as a flag. Only--project=-home-fooworks. - Its
--diagnoseadvice fired "Bash dominates" on both big sessions. With a 98% cache hit rate, each of those calls is billed at a tenth of the input price, so the advice aims at the wrong cost. Its cache advice (mark context withcache_control) is for API users. You can't set that from Claude Code. - Its "top expensive turns" list prints the first 80 characters of each assistant message. Paste that into a bug report and you may paste text from your session.
What you can trust
Cache hit rate, computed as read / (read + write + fresh input). It held up in every run: 98.3% on a long session, 53.1% on a two-turn Haiku run. Repeated lines barely move a ratio.
If you write your own counter: drop repeated message id : requestId pairs, keep the price table current, and split headless runs from real sessions by entrypoint. Test it on a real transcript, not a tidy fake one. My own usage page reads the same lines, and from reading its code it may have the same repeat problem. I haven't checked it against real numbers yet.
Tiếng Việt