Desoul Review Tiếng Việt

← Guides

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

  1. 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.
  2. 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.
  3. 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.

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

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.

Tools in this test