cost — Cowork → Claude API cost estimator
Overview
Claude Cowork (and Claude Code) already run on the Claude API and write one JSONL
transcript per conversation under ~/.claude/projects/. Every assistant turn records
the actual API call it made, including the prompt-cache breakdown. This skill reads
those transcripts, sums the real token usage, and prices it at Anthropic list rates
(cache-aware) so a business user can judge what their conversations would cost on the
API instead of the subscription.
It answers three things:
- Token count (current conversation and/or per conversation across history).
- Exact tokens needed to replay the same multi-turn, tool-using conversation on the API.
- Cost of those tokens in USD and EUR, accounting for prompt-cache hits.
When to Use This Skill
Use it when the user wants the token count or the API-equivalent cost of their Cowork /
Claude Code usage — for one conversation or all of them — or asks to compare subscription
vs API pricing.
How to Run
The worker is cost.py, located in this skill's folder. Run it with the system Python.
Pick the mode from the request:
- current (default) — the active conversation. Use for "this conversation", "current chat".
- history — every conversation with per-conversation + total cost. Use when the user
says "all", "history", "per conversation", "each conversation", "everything".
Run the script with --json so you can render the result yourself:
python "${CLAUDE_SKILL_DIR}/cost.py" --mode current --json
python "${CLAUDE_SKILL_DIR}/cost.py" --mode history --json
Keep the quotes — the path can contain spaces. If the command above still shows a
literal ${CLAUDE_SKILL_DIR}, your surface doesn't substitute it: cost.py sits in the
same folder as this SKILL.md, so locate it with Glob (**/cost/cost.py) and run
the path you find.
Options:
--rate-eur 0.92 — EUR per 1 USD (approximate, editable). Pass a current rate if the
user gives one.
--include-subagents — also count subagent API calls (more complete cost). Use it when
the user wants the full picture or asks about agents/subagents.
Render the JSON as a short English report. Show the token breakdown
(uncached input / cache read / cache write / output / total) and the cost in USD
and EUR. In history mode, present a ranked table (most expensive first) with a TOTAL row.
Money formatting — always use exactly two decimals. Each cost object carries
ready-to-render strings: use usd_display (e.g. $1.23) and eur_display (e.g.
€1,13) verbatim. The euro figure uses a comma as the decimal separator. Do not
re-derive the amounts from the numeric usd/eur fields.
Graceful Fallback (run outside Cowork / Claude Code)
If the script returns {"status": "unavailable", ...}, it found no transcripts — this
happens when it's run outside Cowork or Claude Code. Do not invent numbers. Relay the
message field kindly and verbatim in tone: explain that transcripts only exist inside a
Cowork / Claude Code session, and invite the user to run it from there. Keep it friendly,
not an error.
Reporting Notes (always include briefly)
- The figures are the actual API calls the conversation made, priced at Anthropic list
rates including prompt-cache discounts (cache read ≈ 0.1×, 5-min write 1.25×, 1-hour write
2× of base input) — not an estimate.
- This is the API pay-per-token cost; the Cowork/Claude subscription bills differently,
so treat it as a comparison, not your actual invoice.
- If the output lists
unknown_models, mention those calls were counted as tokens but priced
at $0 because their rate isn't in the table yet (add them to PRICES in cost.py).
- If the output lists
estimated_models, say so explicitly — those models are newer than
the price table, so they were priced with their series' most recent known rate (e.g.
"claude-opus-5-1 was priced at the claude-opus-5 rate because it's newer than the
table"). Their cost is included in the total, so without this caveat a fallback
estimate reads as a confirmed figure.
- In Cowork,
--mode history sees only the current conversation — the sandbox
exposes just the active session's project folder, not the whole archive. Say so instead
of presenting one conversation as the user's full history. Claude Code sees everything.
- Current rates are verified in the
claude-api skill. Before adding a row to PRICES,
look the rate up there rather than guessing.
1---2name: cost3description: Estimate what Claude Cowork / Claude Code conversations would cost if run on the pay-per-token Claude API instead of the subscription. Reports token counts and cache-aware API cost in USD and EUR, for the current conversation or for the whole history (cost per conversation). Trigger when the user asks things like "how much would this conversation cost on the API", "API cost of my Cowork conversations", "token usage / token count", "cost per conversation", "/cost", or wants to compare subscription vs API pricing.4---56# cost — Cowork → Claude API cost estimator78## Overview910Claude Cowork (and Claude Code) already run on the Claude API and write one JSONL11transcript per conversation under `~/.claude/projects/`. Every assistant turn records12the **actual** API call it made, including the prompt-cache breakdown. This skill reads13those transcripts, sums the real token usage, and prices it at Anthropic list rates14(cache-aware) so a business user can judge what their conversations would cost on the15API instead of the subscription.1617It answers three things:181. **Token count** (current conversation and/or per conversation across history).192. **Exact tokens** needed to replay the same multi-turn, tool-using conversation on the API.203. **Cost** of those tokens in **USD and EUR**, accounting for prompt-cache hits.2122## When to Use This Skill2324Use it when the user wants the token count or the API-equivalent cost of their Cowork /25Claude Code usage — for one conversation or all of them — or asks to compare subscription26vs API pricing.2728## How to Run2930The worker is `cost.py`, located in this skill's folder. Run it with the system Python.31321. **Pick the mode** from the request:33 - **current** (default) — the active conversation. Use for "this conversation", "current chat".34 - **history** — every conversation with per-conversation + total cost. Use when the user35 says "all", "history", "per conversation", "each conversation", "everything".36372. **Run the script with `--json`** so you can render the result yourself:3839 ```40 python "${CLAUDE_SKILL_DIR}/cost.py" --mode current --json41 ```42 ```43 python "${CLAUDE_SKILL_DIR}/cost.py" --mode history --json44 ```4546 Keep the quotes — the path can contain spaces. If the command above still shows a47 literal `${CLAUDE_SKILL_DIR}`, your surface doesn't substitute it: `cost.py` sits in the48 same folder as this `SKILL.md`, so locate it with Glob (`**/cost/cost.py`) and run49 the path you find.5051 Options:52 - `--rate-eur 0.92` — EUR per 1 USD (approximate, editable). Pass a current rate if the53 user gives one.54 - `--include-subagents` — also count subagent API calls (more complete cost). Use it when55 the user wants the full picture or asks about agents/subagents.56573. **Render the JSON as a short English report.** Show the token breakdown58 (uncached input / cache read / cache write / output / **total**) and the cost in **USD59 and EUR**. In history mode, present a ranked table (most expensive first) with a TOTAL row.6061 **Money formatting — always use exactly two decimals.** Each cost object carries62 ready-to-render strings: use `usd_display` (e.g. `$1.23`) and `eur_display` (e.g.63 `€1,13`) verbatim. The euro figure uses a **comma** as the decimal separator. Do not64 re-derive the amounts from the numeric `usd`/`eur` fields.6566## Graceful Fallback (run outside Cowork / Claude Code)6768If the script returns `{"status": "unavailable", ...}`, it found no transcripts — this69happens when it's run outside Cowork or Claude Code. **Do not invent numbers.** Relay the70`message` field kindly and verbatim in tone: explain that transcripts only exist inside a71Cowork / Claude Code session, and invite the user to run it from there. Keep it friendly,72not an error.7374## Reporting Notes (always include briefly)7576- The figures are the **actual API calls** the conversation made, priced at **Anthropic list77 rates** including prompt-cache discounts (cache read ≈ 0.1×, 5-min write 1.25×, 1-hour write78 2× of base input) — not an estimate.79- This is the **API pay-per-token** cost; the **Cowork/Claude subscription bills differently**,80 so treat it as a comparison, not your actual invoice.81- If the output lists `unknown_models`, mention those calls were counted as tokens but priced82 at $0 because their rate isn't in the table yet (add them to `PRICES` in `cost.py`).83- If the output lists `estimated_models`, **say so explicitly** — those models are newer than84 the price table, so they were priced with their series' most recent known rate (e.g.85 "`claude-opus-5-1` was priced at the `claude-opus-5` rate because it's newer than the86 table"). Their cost **is** included in the total, so without this caveat a fallback87 estimate reads as a confirmed figure.88- In **Cowork**, `--mode history` sees only the **current** conversation — the sandbox89 exposes just the active session's project folder, not the whole archive. Say so instead90 of presenting one conversation as the user's full history. Claude Code sees everything.91- Current rates are verified in the **`claude-api`** skill. Before adding a row to `PRICES`,92 look the rate up there rather than guessing.