cost-counterfactual
What it does
This skill compares your real AI spending with what it would have cost if every task had used one model tier. It is for people who want to know whether automatic model choice is worth it.
When to use it
- βWhen you want to know if picking models automatically is saving you money.
- βWhen you suspect the router uses expensive models too often.
- βWhen you want to compare your spending with using only the cheapest or the most capable model.
Skill link
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-counterfactual/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βIs my automatic model choice actually saving me money compared with always using one model?β
5 new skills a week. 1 minute to read.
How it works
The skill recalculates past token use at the price of each tier and subtracts your real cost. A positive result means the routing saved money, and a negative result means it spent more.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Multi-baseline counterfactual cost analysis. Pairs with the existing observability surface:
cost-budget-checkβ "have we crossed a threshold?" (reactive)cost-projectionβ "when will we cross a threshold?" (predictive)cost-counterfactualβ "is the routing earning its keep?" (comparative) β this one
Algorithm
- Read all
session-*records from thecost-trackingnamespace. - Apply
--sincewindow filter (default all-time). - Sum tokens across
byModel[*]entries for each session. - For each requested baseline (default: all three):
counterfactualUsd = (input Γ tier.input + output Γ tier.output + cache_write Γ tier.cache_write + cache_read Γ tier.cache_read) / 1M
- Compute
savings = counterfactualUsd β actualUsd. - Emit per-baseline totals + savings % across the comparison set.
Smoke transcript (2 sessions: 50K haiku tokens + 50K sonnet tokens)
| Sessions considered | 2 |
| Total input tokens | 100,000 |
| Actual spend | $0.162500 |
| Baseline | Hypothetical | Actual | Savings | % |
| `always-haiku` | $0.025000 | $0.162500 | -$0.137500 | -550.00% |
| `always-sonnet` | $0.300000 | $0.162500 | +$0.137500 | 45.83% |
| `always-opus` | $1.500000 | $0.162500 | +$1.337500 | 89.17% |
How to read negative savings
A negative always-haiku result means the router chose more-expensive models than haiku on tasks haiku could have handled. That's an over-escalation signal:
- Maybe qualityBar is set too high
- Maybe the sonnet/opus session was warranted by complexity but the baseline doesn't know that
- Run
cost optimize(or inspect specific sessions viacost conversation) to investigate
Positive savings quantify the router's win against that baseline. The most informative number is usually always-sonnet β it's the standard "safe default" baseline most teams would pick if they didn't have routing.
When to use
- Quarterly cost review: "We saved $X vs always-Sonnet β here's the proof."
- CI gate:
cost counterfactual --format json | jq '.baselines[1].savingsPct > 30'β fail builds if routing isn't saving β₯30% vs sonnet baseline (workload-shift detector). - Routing-config validation: When introducing a new qualityBar or cost-ceiling, re-run counterfactual to confirm savings didn't regress.
Stationarity caveat
Like all counterfactual analyses, this assumes the same tokens at the same complexity would have produced the same outcome from the baseline model. That's an upper bound β the baseline might have failed and required retries, which the math doesn't capture. Treat the numbers as a quality-blind ceiling.
FAQ
What do negative savings mean?
They mean the routing spent more than the baseline would have. That often means tasks went to a stronger model than they needed.
Which baselines are compared?
Always haiku, always sonnet and always opus, each with its own price table.
Can I limit the time period?
Yes. A since setting limits the analysis to a recent window, and all time is used by default.
Details
Original description by the author
Multi-baseline counterfactual cost analysis. Compares actual session spend to hypothetical always-haiku / always-sonnet / always-opus routing baselines. Answers "is the routing earning its keep?" Negative savings flag over-escalation; positive savings quantify the router's win.
repo: ruvnet/ruflo
Popularity
- GitHub stars
- 81k
- Ranking position
- #1598
- License
- MIT
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
agent-adaptive-coordinator
81kHelps your agent split and rebalance a group of AI agents as the workload changes, choosing a layout that fits the task.
agent-agent
81kTeaches your agent to turn a big goal into an ordered plan of actions, and to replan when conditions change.
agent-agentic-payments
81kHelps your agent manage spending mandates for AI shopping, with spend caps, time windows, merchant rules and signed approvals.
agent-analyze-code-quality
81kHelps your agent review code for quality, finding code smells, technical debt and refactoring ideas without changing the files.
Similar skills
blucli
394kHelps your agent find, play, pause, group, and adjust the volume of Bluesound and NAD speakers through the blu command.
camsnap
394kHelps your agent grab snapshots, short clips, or motion events from network cameras and local webcams that you have set up.
eightctl
394kHelps your agent check and control an Eight Sleep pod, including its temperature, alarms, and sleep schedules.