cost-diff
यह क्या करती है
यह स्किल दो सहेजे गए लागत सारांशों की तुलना करती है और बताती है कि क्या बढ़ा या घटा। जो टीमें जाँचना चाहती हैं कि कोई बदलाव AI खर्च बढ़ाता है या नहीं, उनके लिए यह है।
कब इस्तेमाल करें
- ✓जब कोई कोड बदलाव AI खर्च बढ़ा सकता है और आप उसकी जाँच करना चाहें।
- ✓जब आप रिलीज़ से पहले और बाद की लागत की तुलना करना चाहें।
- ✓जब आपको तय सीमा से ऊपर खर्च बढ़ने पर अपने-आप विफलता चाहिए।
Skill का लिंक
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-diff/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे बदलाव से पहले और बाद के लागत सारांश की तुलना कीजिए और बताइए कि क्या बढ़ा।”
हर हफ़्ते 5 नई skills, 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
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
agent-adaptive-coordinator
81kआपके एजेंट को काम बदलने पर AI एजेंटों के समूह को बाँटने और फिर से संतुलित करने में मदद करती है, और काम के हिसाब से लेआउट चुनती है।
agent-agent
81kआपके एजेंट को बड़े लक्ष्य को क्रमबद्ध कार्यों की योजना में बदलना सिखाती है, और स्थिति बदलने पर योजना फिर से बनाना भी।
agent-agentic-payments
81kAI खरीदारी के लिए खर्च के आदेश मैनेज करने में मदद करती है, जिसमें खर्च की सीमा, समय अवधि, व्यापारी नियम और signed मंज़ूरियाँ शामिल हैं।
agent-analyze-code-quality
81kआपके एजेंट को कोड की गुणवत्ता जाँचने में मदद करती है, बिना फ़ाइलें बदले code smells, technical debt और refactoring के सुझाव खोजकर।
मिलती-जुलती skills
blucli
394kयह आपके एजेंट को blu कमांड से Bluesound और NAD स्पीकर खोजने, चलाने, रोकने, समूह बनाने और वॉल्यूम बदलने में मदद करती है।
camsnap
394kयह आपके एजेंट को नेटवर्क कैमरों और लोकल webcam से स्नैपशॉट, छोटी क्लिप या मोशन इवेंट लेने में मदद करती है, जो आपने सेट किए हों।
eightctl
394kयह आपके एजेंट को Eight Sleep pod की जांच और नियंत्रण करने में मदद करती है, जिसमें तापमान, अलार्म और नींद की समय-सारणी शामिल हैं।