cost-diff
하는 일
이 스킬은 저장된 비용 요약 두 개를 비교해 늘거나 줄어든 항목을 나열합니다. 변경이 AI 지출을 늘렸는지 확인하려는 팀을 위한 스킬입니다.
사용하는 경우
- ✓코드 변경이 AI 지출을 높였을 수 있어 확인하고 싶을 때.
- ✓출시 전후의 비용을 비교하고 싶을 때.
- ✓지출이 정해진 한도를 넘으면 자동으로 실패하게 하고 싶을 때.
스킬 링크
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-diff/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“변경 전후의 비용 요약을 비교하고, 무엇이 늘었는지 알려 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 두 요약 파일을 불러와 총합과 모델별 금액을 비교하고, 변화를 크기순으로 정렬합니다. 증가가 정해둔 한도를 넘으면 오류 코드를 반환할 수 있습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
PR-level cost regression detection. Where cost-counterfactual compares to HYPOTHETICAL baselines (always-haiku/sonnet/opus) and cost-burn compares latest bucket to PRIOR MEAN, cost-diff compares two SPECIFIC known-good snapshots.
| Question | Skill |
|---|---|
| "What would we have spent at always-X?" | cost-counterfactual |
| "Is daily burn accelerating vs prior mean?" | cost-burn |
| "Did THIS PR add spend vs main?" | cost-diff ← this |
Algorithm
Implementation: scripts/diff.mjs. Consumes the
stable JSON contract from cost summary --format json.
- Load
--baselineand--currentJSON snapshots. - Sanity check: both must have
total_cost_usd+sessionCount(cost-summary shape). - Per-key delta:
byTier(haiku/sonnet/opus) andbyModel(each model). - Each entry tagged
added/removed/changedbased on baseline / current zero-ness. - Sort table by
|delta|descending so the biggest movers are at the top. --alert-on-pct N: exit 1 whentotal_pct > N.--alert-on-usd N: exit 1 whentotal_delta_usd > N. Both can be set; first to trigger wins.
PR-gate workflow
# Capture baseline (e.g. on main, via the cost-tracker-smoke CI workflow)
cost summary --format json > baseline.json
# On the PR branch, capture current state
cost summary --format json > current.json
# Compare; fail the PR if total spend grew >10% OR >$5
cost diff --baseline baseline.json --current current.json \
--alert-on-pct 10 --alert-on-usd 5.00
The combination of both flags catches:
- Percent-only fires: a small absolute change but a meaningful shift (e.g. doubling from $0.10 to $0.20 hits +100% but only +$0.10).
- USD-only fires: a large absolute change with a small percent (e.g. growing from $100 to $110 is only +10% but +$10).
Either signal can fail the PR independently — they're OR'd.
--alert-on-class-pct (iter 86)
The two USD-level thresholds above miss a regression class: when ONE
token type grows disproportionately even though total spend grows
modestly. Example: a PR introduces a verbose context-cache pattern,
total spend grows only 10% (under --alert-on-pct 50), but cache_write
tokens grow 900%. The iter-82 driver hides inside the USD signal.
--alert-on-class-pct cache_write:50 exits 1 when cache_write tokens
grow more than 50% baseline → current. Multiple classes can be checked
in one flag (comma-separated):
cost diff --baseline baseline.json --current current.json \
--alert-on-class-pct cache_write:50,output:25
First class to breach wins. Valid classes: input | output | cache_write | cache_read.
Recommended PR-gate triad:
cost diff --baseline ... --current ... \
--alert-on-pct 25 \
--alert-on-usd 5.00 \
--alert-on-class-pct cache_write:100
Three orthogonal signals — pct (total grew), usd (large absolute
jump), class-pct (composition shifted). Each catches what the others
miss; AND-of-OR semantics means any one firing fails the PR.
Smoke transcript (synthetic baseline + current)
| Total spend | $1.000000 | $1.500000 | +$0.500000 | 50.00% |
| Sessions | 10 | 13 | +3 | 30.00% |
## By tier
| opus | $0 | $0.60 | +$0.600000 | new | added |
| sonnet | $0.70 | $0.50 | -$0.200000 | -28.57% | changed |
| haiku | $0.30 | $0.40 | +$0.100000 | 33.33% | changed |
Notice the table is sorted by absolute delta, not alphabetically — the biggest mover (opus newly added) bubbles to the top. Operators reading top-down see "what mattered" first.
Exit codes
| Exit | Meaning |
|---|---|
| 0 | No alert, OR no thresholds set |
| 1 | --alert-on-pct or --alert-on-usd threshold exceeded |
| 2 | Config error (missing files, invalid JSON, malformed snapshot) |
Status column
| Status | Meaning |
|---|---|
added |
This tier/model was $0 in baseline, >$0 in current |
removed |
This tier/model was >$0 in baseline, $0 in current |
changed |
Both baseline and current >$0; delta is the difference |
Entries with baseline === 0 && current === 0 are dropped (nothing to
report).
Composition with cost-summary
cost-diff is the SECOND HALF of a contract that cost-summary started:
the stable JSON shape from cost summary --format json. Both pieces
have been frozen — adding fields to summary is fine; renaming or
removing isn't.
If you're consuming snapshots elsewhere (
자주 묻는 질문
어떤 파일이 필요한가요?
기준선용 하나와 현재 상태용 하나, 두 개의 JSON 형식 비용 요약 파일이 필요합니다.
새 모델을 표시하나요?
네. 각 항목에 추가됨, 삭제됨, 변경됨 표시가 붙어 새 모델이 눈에 띕니다.
변경을 자동으로 막을 수 있나요?
네. 퍼센트 또는 달러 한도를 정해 두면, 둘 중 하나를 넘을 때 점검이 실패합니다.
상세 정보
작성자의 원본 설명
Snapshot delta between two cost-summary JSON outputs. PR-level cost regression detection — answers "what changed between these two specific snapshots?". Pairs with cost-summary's stable JSON contract.
repo: ruvnet/ruflo
인기도
- GitHub 스타
- 81k
- 순위
- #1599
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
agent-adaptive-coordinator
81k작업량이 바뀔 때 에이전트 무리를 나누고 재배치해, 작업에 맞는 배치를 고르도록 에이전트를 돕습니다.
agent-agent
81k큰 목표를 순서가 있는 행동 계획으로 나누고, 조건이 바뀌면 다시 계획하도록 에이전트를 가르칩니다.
agent-agentic-payments
81kAI 쇼핑을 위한 지출 위임장을 관리합니다. 지출 상한, 시간 창, 판매자 규칙, 서명된 승인을 포함합니다.
agent-analyze-code-quality
81k에이전트가 파일을 바꾸지 않고, 코드 품질 문제와 코드 냄새, 기술 부채, 리팩터링 아이디어를 찾아 검토하도록 돕습니다.