Skip to content
usage-cost skill · vendored new in 0.2.0

A subscription hides the meter. The records don't.

usage-cost reads the local session records a coding agent already writes and reports the tokens used plus what that usage would have cost at published API list rates.

Two inputs, both already local
Session records

Transcript files the runtime writes as it works. Token counts are recorded per request whether or not anything prices them.

Rate table

Published list rates, versioned in the skill and stamped into every report.

scripts/rates.json
On this machine
read reconcile price
standard library only
no network access
One figure
$ 15,139.36
52,678 requests · 10.8B tokens · full recorded window

An equivalence, not an invoice.

Illustrative figure — counts perturbed by up to ±10%, costs recomputed from the perturbed counts. Not an actual usage volume.
01 · Why it exists

A flat fee is one number for everything, so it prices nothing.

A subscription bills the same amount whether a week went into one long refactor or a thousand small lookups. Nothing attaches a price to any individual request, so the shape of the work stays invisible: which models carried it, how much of it was cache, whether a change in habit made the volume go up or down. The tokens are recorded on disk anyway and list rates are published, so the two combine into one number.

Already written

No instrumentation, no wrapper, no proxy. The records exist because the runtime wrote them.

Comparable

The rate table is versioned and stamped into the report, so two runs are read against a known set of rates.

Attributable

Per model and per period, so the volume can be traced to where it came from rather than absorbed into a total.

02 · What the number is

That number is an equivalence, not an invoice.

skills/usage-cost/README.md
It answers

How much metered work went through a flat-rate plan — computed entirely from files already on the machine, at published list rates, over a stated window.

It does not answer

What anyone was charged. It does not predict a bill and it is not a reconciliation of one.

Only what this machine wrote is visible, so the figure is a floor, not an account total.

03 · The report

One command, four blocks.

$ python scripts/usage_cost.py
Provenance header
Runtime: claude-code    Window: all recorded usage
Rate table: 2026-08-16 (USD, list rates)    Days: America/Los_Angeles
Period summary
Period                          Requests      Tokens          Cost
------------------------------------------------------------------
Today (2026-08-15)                   974      228.5M        232.25
Yesterday (2026-08-14)             1,754      333.9M        435.29
This week (from 2026-08-10)        9,060        1.7B      2,503.72
Per-model table
By model, over the full window:

Model                               Requests          Tokens          Cost
--------------------------------------------------------------------------
Claude Fable 5                        28,615   6,594,388,669     11,226.52
Claude Opus 4.8                        7,348   1,695,400,179      1,707.17
Claude Opus 4.7                        8,516   1,515,189,685      1,453.50
Claude Opus 5                          2,701     702,639,489        533.76
Claude Sonnet 5                        3,260     214,884,210        141.14
Claude Sonnet 4.6                      2,202      81,621,428         76.97
Claude Haiku 4.5                          14         588,882          0.30
<synthetic>                               22               0  not billable
--------------------------------------------------------------------------
Total                                 52,678  10,804,712,542     15,139.36
Reconciliation footer
Excluded as non-billable: <synthetic>.

Read 978 transcript file(s); merged 71,653 repeated record(s) into their requests.
4,580 request(s) had copies whose counts differed; the most complete snapshot of each was used.

Example output. The shape is a real run — the model mix, the cache-dominated token profile, the duplicate volume — but every count is perturbed by up to ±10% and the costs recomputed from the perturbed counts. Illustrative, not an actual usage volume.

Provenance header

Which runtime, which window, which rate table, and the timezone day boundaries were drawn on. A figure without these four is not comparable to another one.

Period summary

Today, yesterday, and the week so far. Short periods are where a change in habit shows up first.

Per-model table

Requests, tokens, and cost per model id. Requests and tokens rank differently from cost, which is the useful part. Non-billable ids are counted and shown, never silently dropped.

Reconciliation footer

How many files were read, how many repeated records were merged, and how many of those merges had to choose between copies that disagreed. The report shows its own work.

04 · Mechanics

Reconciled, not deduplicated.

The transcript format appends one response several times as it streams, and the copies are not identical — an early copy can hold a small fraction of its final output tokens. Dropping duplicates by identity would undercount; keeping them all would multiply the same request. Copies merge to the largest snapshot per request instead.

Four records, one request
partial
partial
partial
complete
Priced once
largest snapshot

Schematic. Bar lengths stand for recorded output tokens, not measured values.

Cache priced by lifetime

Uncached input, output, cache reads, and each cache-write lifetime are priced separately. On a coding agent the token profile is cache-dominated, so collapsing these would be the largest single error available.

Exact model matching

A model id resolves by exact match, then by the same id with a trailing -YYYYMMDD removed. No prefix matching, no similarity. A near-miss would produce a confident figure at the wrong rate.

Server-side tool requests

Counted, not costed. They appear in the request column so the volume is visible, and contribute nothing to the total.

Batch discount not modeled

The 50% batch rate is deliberately left out. Coding-agent requests are interactive, so applying it would flatter the figure by half for work that could never have been batched.

Local scope

Only what this machine wrote is visible. Work from another laptop, another checkout, or the web client is not in the records and not in the total — the figure is a floor.

Runtimes

claude-code is supported. codex is registered as an explicitly unavailable adapter: it exits 4 with a stated reason rather than implying the runtime does not exist.

05 · Run it

Nothing to install.

The skill vendors its implementation and uses the standard library only. It reads local files and makes no network calls, so there is no package to add and no version to keep in step.

python scripts/usage_cost.py github ↗ changelog ↗
Form
Vendored
Release
0.2.0
Dependencies
None
Network
None
Runtime
Claude Code
License
Apache-2.0
← all tools & skills memory-lint →