cost-counterfactual
하는 일
이 스킬은 실제 AI 지출을, 모든 작업에 한 모델 등급만 썼을 때의 비용과 비교합니다. 자동 모델 선택이 가치가 있는지 알고 싶은 사람을 위한 스킬입니다.
사용하는 경우
- ✓모델을 자동으로 고르는 것이 돈을 아끼는지 알고 싶을 때.
- ✓라우터가 비싼 모델을 너무 자주 쓰는 것 같을 때.
- ✓가장 저렴한 모델이나 가장 강력한 모델만 쓴 경우와 지출을 비교하고 싶을 때.
스킬 링크
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-counterfactual/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“자동 모델 선택이 항상 한 모델만 쓰는 것보다 실제로 돈을 아끼고 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 과거 토큰 사용량을 각 등급의 가격으로 다시 계산하고, 실제 비용을 뺍니다. 결과가 플러스이면 라우팅이 돈을 아낀 것이고, 마이너스이면 더 많이 쓴 것입니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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.
자주 묻는 질문
절감액이 마이너스이면 무슨 뜻인가요?
라우팅이 기준선보다 더 많이 썼다는 뜻입니다. 필요한 것보다 강력한 모델로 작업이 갔다는 의미인 경우가 많습니다.
어떤 기준선과 비교하나요?
항상 haiku, 항상 sonnet, 항상 opus를 각각의 가격표로 비교합니다.
기간을 제한할 수 있나요?
네. since 설정으로 최근 기간만 분석할 수 있으며, 기본값은 전체 기간입니다.
상세 정보
작성자의 원본 설명
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
인기도
- GitHub 스타
- 81k
- 순위
- #1598
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
agent-adaptive-coordinator
81k작업량이 바뀔 때 에이전트 무리를 나누고 재배치해, 작업에 맞는 배치를 고르도록 에이전트를 돕습니다.
agent-agent
81k큰 목표를 순서가 있는 행동 계획으로 나누고, 조건이 바뀌면 다시 계획하도록 에이전트를 가르칩니다.
agent-agentic-payments
81kAI 쇼핑을 위한 지출 위임장을 관리합니다. 지출 상한, 시간 창, 판매자 규칙, 서명된 승인을 포함합니다.
agent-analyze-code-quality
81k에이전트가 파일을 바꾸지 않고, 코드 품질 문제와 코드 냄새, 기술 부채, 리팩터링 아이디어를 찾아 검토하도록 돕습니다.