api-bill
Use when the owner asks what their Claude Code use would cost on the API, wants an API shadow bill or cost card for a time frame, or types /api-bill (with a time frame such as 24h, 7d, 30d, 6m or all)
SKILL.mdapi-bill/skill/SKILL.md
GitHubAPI shadow bill
$BILL below is python "$HOME/.claude/skills/api-bill/scripts/apibill.py".
- Take the time frame from the request:
24h,7d,2w,30d,6m,1yorall. Default30d. - Run
$BILL <timeframe>. It fetches the live pricing page, reads every Claude Code log on this PC (subagents included), prices each reply at the rate of the model that wrote it, and writes the card to~/api-bill/.- Never edit the price list or guess a rate. A model with no list price is left out and named as unpriced; say so.
- Publish the card as a private Artifact, the same link every run:
- Read
artifact_urlfrom~/api-bill/config.json. - If it is set:
Artifactwithaction: "read"on that url, then publish withurlset to it andfile_pathset to the card path the script printed. - If it is not set: publish the card with
icon: "chart"and nourl, then save the returned link asartifact_urlin~/api-bill/config.json, keeping the other keys. - Never share it or make it public: it holds project names and usage.
- If the Artifact tool is not available in this session, give the local card
path instead and offer to open it (
$BILL <timeframe> --open).
- Read
- Reply with the script's first line (the API cost), the per-model split, any unpriced models, a stale-price warning if the script printed one, the "Includes an estimate" or "No estimate" line if there is one, and the link.
Claude Code deletes session logs after its cleanup period (30 days by default), so
for longer time frames the days before the oldest kept log come from the running
totals /stats keeps in ~/.claude/stats-cache.json. /stats adds up every log line
and each reply is written as several lines, so its token counts run several times
high; the script measures that overcount on the days both exist and divides it out.
That part is an estimate, and its cache writes are priced at the 5-minute rate, so
it is a lower bound. Per-project and per-day breakdowns cover only the logged days.
Without the cache file or a day both cover, there is no estimate and the card says
why.
The card says which prices it used and the date they were fetched. If the live page could not be fetched it uses the last saved prices and says so on the card.