cost-budget — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited cost-budget (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Autonomous AI workflows can consume unbounded resources without guardrails. A single runaway loop — autopilot, ralph, or a multi-wave taskMaestro session — can burn through API credits before anyone notices.
Core principle: Every autonomous workflow must have a cost ceiling. No budget means unlimited spend.
Iron Law:
NO AUTONOMOUS EXECUTION WITHOUT A DECLARED BUDGET
If no budget is set, warn before starting. If budget is exceeded, pause and require override.Cost data is collected at three levels:
| Level | Scope | Data Source | Granularity |
|---|---|---|---|
| Session | Single Claude Code session | Token usage from API responses | Per-request |
| Wave | One taskMaestro wave (N parallel panes) | Aggregated session costs per pane | Per-wave |
| Project | All sessions in a project directory | Cumulative across sessions | Running total |
Cost = (input_tokens × input_price) + (output_tokens × output_price)
Model pricing (per 1M tokens):
opus: input=$15.00 output=$75.00
sonnet: input=$3.00 output=$15.00
haiku: input=$0.25 output=$1.25Note: Prices are approximate and should be updated when model pricing changes. The skill defines the protocol, not hardcoded prices.
export COST_BUDGET_USD=10.00 # Total budget in USD
export COST_BUDGET_TOKENS=5000000 # Alternative: token-based budget
export COST_BUDGET_SCOPE=project # session | wave | projectcodingbuddy.config.json): {
"costBudget": {
"limit": 10.00,
"currency": "USD",
"scope": "project",
"thresholds": {
"info": 0.50,
"warn": 0.80,
"critical": 1.00
}
}
} state_write(mode: "cost-budget", state: {
"spent": "4.52",
"budget": "10.00",
"tokens_used": "2340000"
})Track tokens per request and accumulate:
Per request:
input_tokens → from API response headers or usage field
output_tokens → from API response headers or usage field
cost_usd → calculated from model pricing
Accumulated:
session_total = sum(all request costs in session)
wave_total = sum(all session costs in wave)
project_total = sum(all wave/session costs in project)Three threshold levels trigger different actions:
| Level | Default | Trigger | Action |
|---|---|---|---|
| INFO | 50% of budget | Informational milestone | Log to terminal, continue |
| WARN | 80% of budget | Approaching limit | Terminal alert + optional webhook, continue |
| CRITICAL | 100% of budget | Budget exhausted | Terminal alert + webhook + auto-pause |
| Scope | Description | Use Case |
|---|---|---|
session | Single CLI session | Quick tasks, one-off work |
wave | One taskMaestro wave | Per-wave cost control in parallel execution |
project | Cumulative across all sessions | Long-running projects with total budget |
When the CRITICAL threshold is reached, the workflow pauses. To continue:
# Explicit override for current session
export COST_BUDGET_OVERRIDE=true
# Or increase the budget
export COST_BUDGET_USD=20.00Override rules:
Always active. Alerts appear inline in the terminal:
┌─────────────────────────────────────────────┐
│ 💰 COST ALERT [INFO] │
│ Budget: $5.00 / $10.00 (50%) │
│ Tokens: 1.2M used │
│ Status: Continuing │
└─────────────────────────────────────────────┘┌─────────────────────────────────────────────┐
│ ⚠️ COST ALERT [WARN] │
│ Budget: $8.00 / $10.00 (80%) │
│ Tokens: 3.8M used │
│ Status: Approaching limit — review spend │
└─────────────────────────────────────────────┘┌─────────────────────────────────────────────┐
│ 🛑 COST ALERT [CRITICAL] │
│ Budget: $10.00 / $10.00 (100%) │
│ Tokens: 5.0M used │
│ Status: PAUSED — override required │
│ │
│ To continue: │
│ export COST_BUDGET_OVERRIDE=true │
│ # or increase: export COST_BUDGET_USD=20 │
└─────────────────────────────────────────────┘For remote notifications (Slack, Discord, PagerDuty, custom endpoints):
export COST_ALERT_WEBHOOK_URL=https://hooks.slack.com/services/...
export COST_ALERT_WEBHOOK_EVENTS=warn,critical # which levels trigger webhookWebhook payload:
{
"event": "cost_alert",
"level": "warn",
"budget_usd": 10.00,
"spent_usd": 8.00,
"percent": 80,
"tokens_used": 3800000,
"scope": "project",
"project": "codingbuddy",
"session_id": "abc-123",
"timestamp": "2026-03-22T14:00:00Z"
}Webhook rules:
When the CRITICAL threshold (100%) is reached:
| Workflow | Pause Point | What Happens |
|---|---|---|
| autopilot | Between iterations | Current iteration completes, next blocked |
| ralph | Between architect reviews | Current cycle completes, next blocked |
| ultrawork | Between task assignments | Current task completes, next blocked |
| taskMaestro | Between waves | Current wave completes, next wave blocked |
| parallel agents | At agent completion | Running agents finish, no new agents spawn |
Key: Never interrupt mid-operation. Always complete the current atomic unit, then pause.
1. User sees CRITICAL alert
2. User reviews spend breakdown
3. User decides:
a. Stop entirely → no action needed, workflow stays paused
b. Continue with new budget → export COST_BUDGET_USD=<new_amount>
c. Continue without limit → export COST_BUDGET_OVERRIDE=true
4. Workflow resumes from saved stateWhen running taskMaestro with a project budget, allocate per-wave:
Total budget: $20.00
Estimated waves: 4
Per-wave allocation: $5.00 per wave
Wave 1: $5.00 budget → actual: $3.20 → remaining pool: $16.80
Wave 2: $5.60 budget (redistributed) → actual: $4.10 → remaining pool: $12.70
Wave 3: $6.35 budget (redistributed) → ...Redistribution rule: Unspent budget from completed waves rolls into remaining waves equally.
Each tmux pane in a taskMaestro wave runs an independent session. Aggregation:
Wave cost = sum(pane_1_cost + pane_2_cost + ... + pane_N_cost)
Tracking via shared state:
state_write(mode: "cost-budget", state: {
"wave_id": "wave-2",
"pane_id": "pane-3",
"pane_cost": "1.25",
"wave_budget": "5.60"
})After each pane completes, check the wave aggregate:
1. Pane completes → reports cost to shared state
2. Orchestrator reads all pane costs for current wave
3. Calculate: wave_spent = sum(all pane costs)
4. Check: wave_spent vs wave_budget
5. If WARN → alert, continue remaining panes
6. If CRITICAL → let running panes finish, block next waveBefore starting an autonomous workflow:
COST_BUDGET_USD or config)session / wave / project)During execution:
After completion:
| Thought | Reality |
|---|---|
| "It's just a quick autopilot run, no budget needed" | Quick runs become long runs. Set a budget. |
| "I'll check the cost later" | Later is after the money is spent. Track now. |
| "The budget is too small, I'll just override" | If you're always overriding, your budget is wrong. Increase it properly. |
| "Token counting is too much overhead" | API responses include token counts. No extra cost to read them. |
| "I'll skip the webhook, terminal alerts are enough" | You won't see terminal alerts if you walk away. Set up webhooks for unattended runs. |
| "One pane won't affect the total budget much" | Parallel panes multiply cost linearly. 8 panes = 8x the cost rate. |
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.