Which task spent your token budget?

cctaskcost reads the Claude Code session logs already on your disk and prints the cost of one prompt at a time. Read-only, no API key, no network call.

How this was built: five stages, three skill pairs, with the evidence

$ python cctaskcost.py --files 3 --top 8 --cache

3 session file(s), 8 task(s) shown

     COST    TOKENS  TURNS  CACHED  TASK
-----------------------------------------------------------------
$ 31.5785     37.9M    186     97%  run stages A-E, output a receipt
$ 16.6463      8.9M     42     86%  add a timeout to the flaky test
$  7.2387      1.2M      5     40%  turn on Pages for the docs folder
$  6.8380      1.5M      7     57%  check the example is complete
$  3.6085      5.4M     19     99%  add two allow rules
$  2.4088    713.0k      8     72%  read the handoff and summarise it
$  1.4068    139.4k      2      0%  /i-have-adhd
$  1.2755      1.2M     14     90%  rename the repo, update the links

total shown: $71.0011   (list prices; edit with --prices)
8 task(s) in 3 session files
cost / tokens / turns / cached

$31.5785  37.9M 186t  97%
  run stages A-E, output a receipt

$16.6463   8.9M  42t  86%
  add a timeout to the flaky test

$ 7.2387   1.2M   5t  40%
  turn on Pages for the docs folder

$ 6.8380   1.5M   7t  57%
  check the example is complete

$ 3.6085   5.4M  19t  99%
  add two allow rules

total shown: $71.0011

About that total. A subscription plan does not bill you per token. On a plan, read every figure here as what the task would have cost on the API. That is still the number that tells you which task to change.

About that output. Every figure above is from one real run. The task labels were shortened and reworded, because the originals held local file paths, and on a narrow screen the same rows are restacked to fit. Prices are list prices as of 2026-09-26; check them against the pricing page before you trust a figure.

The four flags above: --files 3 reads the three newest session files, --top 8 prints eight rows, --cache adds the cached column, and --prices swaps the built-in price table for your own.

Why another usage tool

ccusage and the other monitors total a session, a day or a 5-hour block. That answers how much today cost. It does not answer which of today's eleven prompts cost $50.

Per prompt, not per session
Seven comparable tools were checked on 2026-09-26. Every one reports a session, a day or a live total.
Nothing leaves the machine
It opens local files and prints to your terminal. No API key, no network call, no telemetry.
One file, standard library only
Python 3.8 or later. No dependencies to install and nothing to configure.

The problem, in other people's words

The cached column exists because of that third one. It is the share of charged input that was served from cache, and a cache read costs about a tenth of a fresh input token. A saving claim you can check beats one you cannot.

How the attribution works

Your session logs live in ~/.claude/projects/<project>/<session>.jsonl, one JSON record per line. Three record types matter.

recordcarries promptIdcarries usage
user, your promptyesno
user, a tool resultyes, the same oneno
assistantnoyes

So each assistant record is charged to the most recent promptId seen in file order. A tool result never opens a new task, because it repeats the id of the prompt that caused it. That one grouping step is the whole tool.

Try it without touching a real log

git clone https://github.com/az9713/skill-chaining
cd skill-chaining
python cctaskcost.py demo

demo builds a session log in a temporary folder, asserts the grouping and the prices are right, prints demo: ok, and deletes it. It reads none of your own logs. When you are satisfied, run the real thing:

python cctaskcost.py --files 3 --top 8 --cache