cost-review
Skill130 starsChanged 5 days agoMITView on GitHub
Analyze AI coding spend across harnesses (Amp, Claude Code, Codex) and attribute cost changes with a five-term decomposition.
- Reads credentials
3 other projects use a version of this.
Adopted by
Most recently taken up by
- RoboFinSystems/robosystemstheir own version, first seen Nov 30, 2026
- DataWithBaraa/claude-code-data-engineering-skillstheir own version, first seen Nov 1, 2026
- bakhod1r/awesome-agentstheir own version, first seen Oct 15, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- DataWithBaraa/claude-code-data-engineering-skills★ 84same name
- RoboFinSystems/robosystems★ 31same name
- bakhod1r/awesome-agents★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository39 other files it gives its agents.
- AGENTS.mdAGENTS.md
- wiki/AGENTS.mdAGENTS.md
- wiki/CLAUDE.mdCLAUDE.md
- accountable-engineeringSkill
- adrSkill
- babysit-prSkill
- blindspot-passSkill
- capability-experimentsSkill
- codemapSkill
- code-quality-reviewSkill
- code-reviewSkill
- commit-atomicSkill
- context-discoverySkill
- diagnosing-bugsSkill
- doc-searchSkill
- docs-updateSkill
- draft-pull-requestSkill
- git-contextSkill
- handoffsSkill
- implementation-loggerSkill
- implement-specSkill
- llm-wikiSkill
- orchestrating-fusionSkill
- pickupSkill
- plannotator-setup-goalSkill
- portless-localSkill
- prdSkill
- pr-reviewSkill
- prSkill
- qmd-knowledgeSkill
- quiz-meSkill
- ralphSkill
- retroSkill
- security-auditSkill
- slopSkill
- spec-interviewSkill
- tddSkill
- tmuxSkill
- visual-prSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Use when the user asks:
- Very specific: line 52
Check whether the input total already includes cached tokens, and price cached and non-cached input separately so nothing is counted twice.
- Distinctive: line 162
Every number carries its source.
- Distinctive: line 165
If two sources disagree, report both and name the discrepancy instead of averaging.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cost Review
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.
When to Use
Use when the user asks:
- "How much are we spending on AI tools?"
- "Why did my usage/cost jump this week?"
- "Which model tier is worth its cost?"
- "Set up spend nudges before I burn the budget."
Data Sources
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 |
Confirm the log schema before aggregating
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.
Method: Five-Term Decomposition
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:
- The previous period has no usage. Against a zero baseline the percentage change and the per-term split are undefined. Report the spend as new activity with its absolute amount, and mark the percentage and the per-term split as unavailable.
- The current period has no usage yet. With zero current usage there is nothing to attribute and no factors to compute; a negative spend against zero usage (a refund) behaves the same. Report the spend and the gap, and mark the percentage and the per-term split as unavailable.
- A factor cannot be observed, or the two periods are not comparable.
Exact reconciliation is required only when both periods have complete,
comparable cost data. Otherwise report the observed total change, list
the factors that are
unknown, and state what prevents the attribution — never manufacture a complete split.
Output
- Decomposition table — one row per term: value now, value last period, attributed delta, and the source file or command behind it.
- Per-harness spend breakdown — one line per harness: its amount and
the source behind it. A harness whose total cannot be observed is listed
as
unknown, never omitted. - Attribution sentence — e.g. "the +38% came from turns/session (+41%, longer coordinator sessions), partly offset by price/token (-9%, cheaper model mix on mechanical work)".
- Cost per unit — cost per merged PR, per review, or per landed task if the data supports it. Pair it with a quality signal when one exists (revert rate, review findings) so cheap is not confused with good.
- Spend nudges — if a weekly budget is set (
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 isunknown, 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:- under 50% spent: quiet.
- 50% up to but not including 80% spent: one line in the reply naming the projection.
- 80% up to and including 100% spent: recommend concrete levers (route mechanical work to a cheaper tier, batch tool calls through a shell, raise the compaction threshold if the harness supports that control).
- over 100%: recommend pausing non-blocking work until the reset.
Levers, by term
- sessions / turns: long-lived sessions on short cache TTLs re-pay full input price after every idle gap. Prefer a longer prompt-cache TTL for the long-running session, not more restarts.
- requests/turn: chatty tool loops (polling, file-by-file reads) are the usual offender; batch them in one shell command.
- tokens/request: preloaded MCP schemas and pasted logs; use deferred tool loading and grep/tail scoped output instead.
- price/token: route mechanical work (log scans, bookkeeping, formatting) to the cheapest capable tier. Model choice is the single biggest lever, but check the other terms before reaching for it.
Guardrails
- Every number carries its source. An unsourced number is a guess, not a finding.
- Absolute savings from other teams (Uber, Warp) do not transfer; only the decomposition method does.
- If two sources disagree, report both and name the discrepancy instead of averaging.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

