runaway-guard
Cost-safety discipline for paid AI / inference APIs: treat $-cost as a third complexity dimension alongside time and space. Forces a written per-run $-cap, per-day $-cap, max-iterations bound, concurrency limit, and a matching provider-dashboard hard cap BEFORE any call site is written.
npx skills add majiayu000/claude-skill-registry --skill runaway-guard --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Enforces cost-safety discipline for paid AI / inference APIs by treating dollars-per-execution as a third complexity dimension alongside time and space. Requires a written per-run dollar cap, per-day dollar cap, a concrete max-iterations bound, a concurrency limit, and a matching provider-dashboard hard cap before any call site is authored. It instructs developers to state a max calls per run, max dollars per run, and max dollars per day, and to mirror these caps in the provider dashboard. It emphasizes preventing unbounded retries, queueing, or self-rescheduling from incurring real costs.
How it works
The skill directs the developer to declare concrete caps in code before any paid-API call:
- Define a constant for max calls per run and compute max dollars per run from unit_cost.
- Specify a provider hard cap per day on the dashboard and mirror it in code.
- Set a concurrency limit on the call path (e.g., through the queue or processor configuration).
- Use an idempotency key strategy for mutating or charging calls to avoid duplicate charges.
- Include a cost contract comment above the call site detailing provider, unit cost, max calls per run, max $ per run, provider hard cap, concurrency, and retry policy.
- If the input or loop exceeds the explicit max, throw a NonRetriableError or equivalent to prevent partial processing.
- Apply a termination bound within loops that call paid APIs, ensuring a concrete iteration limit and preventing unbounded fan-out.
- For fan-out or retries, ensure total cost and attempts respect the defined wallet invariants and that amplifier patterns are audited.
When to use it
Use when writing or reviewing code that calls a paid AI / inference API in loops, queues, retry paths, agent steps, webhook handlers, or background jobs; when wrapping paid-inference SDKs; when designing agent loops or pollers that may incur charges; and when auditing for unbounded fan-out, unbounded retries, or missing provider spend caps.
What it can touch
Declared tools include claude-code, antigravity, cursor, gemini-cli, codex-cli. The skill applies to code paths that call paid APIs and requires you to implement cost-capped call sites, provider hard caps, and concurrency controls. It specifies to place the code and cost contract in the call site with explicit constants and idempotency keys.
Caveats
License: Apache-2.0. Risk: safe. It notes that the protocol cannot fix a bug in upstream fetch logic and that the cost controls mitigate but do not eliminate all bugs; the cost contract exists to cap potential spend and to require hard caps before deployment. The guidance emphasizes defense in depth by pairing code-side caps with provider-side caps to prevent budget overruns.
# runaway-guard — $-Cost is the Third Complexity Dimension Every loop has time complexity and space complexity. A loop that calls a paid API has a third: **dollars per execution**. The model tracks the first two automatically. It does not track the third, so it ships code where a single bug — a retry without bound, a stream reconnect storm, an agent that re-queues itself, a webhook that fires the same job twice — silently spends real money. The canonical incident: developer writes a Fal.ai image-generation loop. Loop "obviously terminates" because it iterates over a fixed list. The list comes from a callback that fires on every Inngest retry. Each retry doubles the list. By morning, the bill is **$200**. Tests pass. Code review passed. The bug is not in the loop body. The bug is that **no one stated the wallet invariant**. runaway-guard fixes this. State the max calls. State the max dollars per run. State the max dollars per day. Set the same caps in the provider dashboard so a code bug cannot bypass them. Then write the code. **Violating the letter of these rules is violating the spirit of the skill.** "I'm only testing locally" is the exact rationalization that ships the $200 bil
- When to Use This Skill
- The Iron Law
- Non-negotiable rules
- The pre-write protocol
- Worked trap — the Inngest + Fal $200 night
- Common runaway patterns and their wallet invariants
- Provider-specific cheat sheet
- Fal.ai
- Anthropic
- OpenAI
- Replicate
- ElevenLabs
- Inngest (queue layer — not paid AI but the multiplier)
- Edge cases to enumerate before shipping
What does the runaway-guard skill do?
Cost-safety discipline for paid AI / inference APIs: treat $-cost as a third complexity dimension alongside time and space. Forces a written per-run $-cap, per-day $-cap, max-iterations bound, concurrency limit, and a matching provider-dashboard hard cap BEFORE any call site is written.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill runaway-guard --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
