The guide identifies possible usage data sources, explains how to validate log schemas and attribute cost changes without an unexplained residual, and specifies how to report spend, uncertainty, and budget nudges. It also provides cost-reduction levers and guardrails, including when to mark figures unknown or when paid API access is allowed.
Attribute AI coding spend instead of summing it. A total answers nothing; a per-term decomposition answers "what changed". Follow the Uber software-factory method: decompose cost into five terms and attribute the week-over-week change term by term, with no unexplained residual.
Use when the user asks:
Gather what is locally available. Never call a paid API to answer a cost
question unless the user provides the key and asks for it. Cite the source
next to every number; if a term cannot be observed, mark it unknown — do
not invent it.
| Harness | Source | Command / location |
|---|---|---|
| Amp | CLI usage report, if the installed version provides one | amp usage (fall back to the harness's usage tool, e.g. the MCP get_usage tool, or the Amp web dashboard) |
| Claude Code | Local transcript JSONL | npx ccusage@20.0.51 daily (version pinned so every review runs the same release; bump deliberately) reading ~/.claude/projects/**/*.jsonl; raw counts: ~/.claude/projects/**/*.jsonl message.usage fields |
| Codex | Local session logs | ~/.codex/sessions/**/*.jsonl token fields, or the OpenAI usage API with a user-provided OPENAI_API_KEY |
| Any | Platform dashboards | Ask the user to paste the numbers; record the source and date |
Local logs differ per harness and per release. Before aggregating any token
fields, confirm the schema you are reading and whether the counters are
cumulative: where they are (Codex session logs can be), aggregate counter
changes inside the reporting window, never a sum of cumulative snapshots.
Check whether the input total already includes cached tokens, and price
cached and non-cached input separately so nothing is counted twice. When a
schema or the applicable rates cannot be confirmed, report that spend as
unknown and say what would confirm it.
Define one unit of work (a session, a task, a PR — state which you used). Then:
cost = sessions x turns-per-session x requests-per-turn x tokens-per-request x price-per-tokenCompute each derived factor as a ratio of the period's totals — turns divided by sessions, requests divided by turns, tokens divided by requests, spend divided by tokens — never as an average of per-unit values. Ratios of totals cancel across the product, so the factors multiply back to each period's total cost exactly, which is what lets the walk reconcile; an average of per-unit values does not.
For each term, compute this period and last period, then attribute the cost delta with sequential substitution: walk the terms in a fixed order — sessions, turns per session, requests per turn, tokens per request, price per token — and for each term recompute the total with that term at its current value, earlier terms at their already-updated values, and later terms at their previous values; give that term the difference from the previous step. State the order in the report, because it affects the allocation when several terms move together.
The walk is required, not cosmetic: cost is a product, so the terms' percentage deltas do not add. Example: sessions 100 → 200 and turns per session 10 → 20, tokens per request fixed. Baseline 100 × 10 = 1,000 units; observed 200 × 20 = 4,000. Substitution attributes +1,000 to sessions (200 × 10 = 2,000) and +2,000 to turns/session (200 × 20 = 4,000): the sums reconcile. Attributing each factor's own +100% to the 1,000-unit baseline would give +1,000 + +1,000 = 2,000, leaving 1,000 unexplained despite perfectly consistent data. The attributed amounts always sum exactly to the observed change; if they do not, the data or arithmetic is wrong — fix it, do not publish a residual. Uber used this to explain a 34% unit-cost drop with the model held fixed; the point is that "model price" is usually not the term that moved.
Cache pricing is not a sixth term: cached input is billed at a fraction of the input price, so it lives inside price-per-token. Either take the cost fields the billing data already carries (ccusage reports costs per model), or split tokens-per-request into cached and non-cached input, each with its own rate. Never price cached tokens at the full input rate — that double-counts them.
Two situations suspend the walk:
unknown, and state what prevents the attribution —
never manufacture a complete split.unknown, never omitted.AI_WEEKLY_BUDGET_USD), pick
the band from the share of the budget actually spent so far, and report the
projected week-end spend alongside it, with the elapsed-time and spending
assumptions the projection rests on. When any harness's spend is
unknown, the observed total is only a lower bound: state the coverage
gap, and do not pick a band or publish a projection from it — except
when the known spend already exceeds the budget, which still establishes
the pause band. The bands do not overlap:
jellydn/my-ai-tools
1524f4a
ampamp usagenpxnpx ccusage@20.0.51npx ccusage@20.0.51 dailygreptailget_usageAlso appears in
since Nov 30, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.