cost-budget-check
Read accumulated cost-tracking spend + budget config, compute utilization, emit 50/75/90/100% alert ladder
Cost Budget Check
Reads cost-tracking:budget-config for the project's budget limit, sums total_cost_usd across session-* records produced by cost-track, computes utilization, and emits the measured 4-tier alert ladder (50% INFO / 75% WARNING / 90% CRITICAL / 100% HARD_STOP).
Until P2 (this skill) landed, the README documented the alert ladder but no code checked it. Now this skill is the gate.
When to use
- After every cost-track run, to surface the alert level.
- Before spawning a swarm β if utilization β₯ 90%, escalate to
/cost-optimizefirst. - Cron-friendly via
/loop 30mfor continuous monitoring.
Steps
-
Run the check:
node plugins/ruflo-cost-tracker/scripts/budget.mjs checkFilter by period:
BUDGET_PERIOD=today(defaultall). UseBUDGET_QUIET=1for machine-readable JSON. -
Inspect the markdown summary β budget, spent, remaining, utilization percentage, alert level (π’ OK Β· π‘ INFO Β· π WARNING Β· π΄ CRITICAL Β· π HARD_STOP), and the recommended action.
-
Set / inspect the budget:
node plugins/ruflo-cost-tracker/scripts/budget.mjs set 50.00 node plugins/ruflo-cost-tracker/scripts/budget.mjs get -
HARD_STOP path β
budget.mjs checkexits with code1when utilization β₯ 100%. Wrap critical agent spawns in abudget.mjs check && spawn β¦guard to fail closed.
Storage shape (cost-tracking:budget-config)
{
"budget_usd": 50.00,
"setAt": "2026-05-05T...",
"thresholds": { "info": 0.50, "warning": 0.75, "critical": 0.90, "hard_stop": 1.00 }
}
Alert ladder (from REFERENCE.md, now enforced)
| Threshold | Level | Action |
|---|---|---|
| 50% | INFO π‘ | log notification, no UX disruption |
| 75% | WARNING π | display warning, suggest /cost-optimize |
| 90% | CRITICAL π΄ | urgent alert, recommend model downgrades |
| 100% | HARD_STOP π | halt non-essential spawns; exit code 1 |
Cross-references
cost-track(producer) β populatescost-tracking:session-*cost-reportβ same data source, narrative formatcost-optimizeβ recommended action when WARNING/CRITICAL- REFERENCE.md "Budget alert thresholds" β the documented ladder this enforces
ruvnet/claude-flow Β· MIT Β· Revision 005a0ed25e64
Be the first to comment
Share what worked or leave a question for the creator.