Plan llm cost guardrails
Skill kensaurus/cursor-kenji/skills/plan-llm-cost-guardrails
π¦Curated Cursor AI agent skills, slash commands, MCP configs, subagents & rules for full-stack dev β React 19, Next.js 15, Supabase, Tailwind v4, TypeScript
npx -y skills add kensaurus/cursor-kenji --skill plan-llm-cost-guardrailsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 6 stars6 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Audit an LLM-powered app for runaway-cost and quota-abuse exposure, then produce a phased guardrail plan. Use when the user says "cap my AI costs", "my LLM bill could blow up", "rate limit my AI", "token budget", "runaway agent loop", or is hardening LLM features before launch. Audits three layers: token-bucket limits, cost-velocity circuit breakers, and fallback chains; also covers Langfuse cost alerts and streaming usage accounting. Plan only until approved. Pairs with audit-langfuse-llm, plan-input-validation. Do NOT use for output quality evals (audit-langfuse-llm).
The file declares its own license as MIT. That is the authorβs claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
5.3 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it
LLM Cost-Guardrail Audit + Remediation Plan
Role: Senior platform engineer (LLM spend + abuse resistance).
Task: Inventory every LLM call site, test against the 3-layer guardrail model,
score unbounded paths, phase remediations, emit plan-llm-cost-guardrails.md.
Audit & plan only β no limits or routing changes until approved.
Find every path to a runaway bill. Cap it. Change nothing until approved.
Token cost scales with input + output tokens, not request count β a single
50K-token context replayed three times can exhaust a budget while staying under any
RPM cap. Vibe-coded AI features ship with no spend cap, no per-user quota, no
max_tokens, no circuit breaker β compounded by prompt-injection cost amplification
and forged-webhook quota fraud (the empty-signing-secret bypass class).
This is the prevention counterpart to Langfuse observability: Langfuse tells you what spend happened; this audits what's capped.
When this fires
Trigger phrases: "cap my AI costs", "my LLM bill could explode", "rate limit my AI", "token budget", "someone could drain my quota", "runaway agent loop", "per-user AI limits", "pre-launch cost hardening".
Do not fire for: output quality/evals (audit-langfuse-llm), generic API
performance, or trace visibility (plan-error-handling). This owns bounded spend.
The audit β 3-layer guardrail model
Layer 1 Β· Limits (token-aware, not request-count)
- Token-bucket / quota per (user, model) β any per-identity limit?
- Token-based, not just RPM β prompt-TPM and output-TPM ceilings.
max_tokens/ context caps β bound worst-case cost; truncate RAG context.- Short + long windows β per-minute burst and per-day/month budget.
- Tiered limits β free vs paid wired to Stripe entitlement.
Layer 2 Β· Circuit breakers
- Cost-velocity breaker β spend/min threshold.
- Loop / repeat detection β retry-storms, growing-context loops.
- Daily-spend kill switch β hard cap backstop.
- Error-rate breaker β mostly-failing caller identity.
Layer 3 Β· Fallback chain
- Primary β cheaper model β cache β graceful 503.
- Semantic cache before paid calls.
- Model routing by complexity β flag everything-to-Opus patterns.
Cross-cutting
- Streaming usage accounting β
stream_options.include_usageor spend is invisible. - Retry discipline β token-aware backoff.
- Abuse vectors β unauthenticated AI endpoints; hand boundary fixes to
plan-input-validation. - Langfuse cost alerts β 50/75/90% thresholds; per-user attribution.
Procedure
- Inventory LLM call sites and public AI endpoints.
- Test each against Layers 1β3.
- Score = worst-case spend Γ reachability.
- Phase β Layer 1 caps and daily kill switch first.
- Emit
plan-llm-cost-guardrails.md. End the turn.
Guardrails
- Plan only. No limits, gateway config, or routing changes.
- Spend cap is non-negotiable for launch β flag absence as at least High.
- Token-aware or it doesn't count β don't credit RPM-only limits.
- Bounded blast radius, not zero runaways.
- Cross-hand abuse to
plan-input-validation.
Report template β plan-llm-cost-guardrails.md
# LLM Cost-Guardrail Audit β <repo>
_Audit-only. No limits or routing change until each phase is approved._
## Scope
- LLM call sites: n | Public AI endpoints: n | Langfuse present: β
## Verdict
| Layer | Present? | Worst gap |
|-------|----------|-----------|
| 1 Limits (token-aware) | partial | unbounded max_tokens |
| 2 Circuit breakers | β | no daily kill switch |
| 3 Fallback chain | β | limit = hard error |
## Findings
| # | Call site | Unbounded path | Worst-case | Missing layer | Sev | Direction |
|---|-----------|----------------|------------|---------------|-----|-----------|
## Phased burndown
- **Phase 1 β Caps & kill switch** β `backend-patterns`
- **Phase 2 β Circuit breakers** β `backend-patterns`
- **Phase 3 β Fallback chain** β `backend-patterns`
- **Phase 4 β Visibility** β `audit-langfuse-llm` / `backend-observability`
- **Cross-hand** β `plan-input-validation`
## Execution handoff
Simulate a runaway in test env after Phase 1; confirm cap holds before bill moves.
Chains with
- Observability & spend loop β pairs with
plan-error-handling(visibility) andaudit-langfuse-llm(quality); this owns bounded spend. - Execution:
backend-patterns,audit-langfuse-llm,backend-observability. - Verify: sandbox load/abuse test β caps, breakers, fallback trip before spend escapes.
Plan with a strong model; execute with
composer-2.5-execution.mdc.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.