/kenji:plan-llm-cost-guardrailsfrom kenji skills
Audits LLM app code for runaway-cost and quota-abuse exposure. Inventories call sites, scores unbounded paths, and phases remediation plans (caps, breakers, fallbacks). Plan-only — no changes.
Ships in kenji skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Degree of freedom: HIGH — inventory call sites, score unbounded paths, plan. Stay plan-only. No limits or routing changes until approved.
| Skill | Owns |
|---|---|
| plan-llm-cost-guardrails (this) | Token / quota / runaway-loop plan |
audit-langfuse-llm | Quality and cost traces |
audit-infra-cost | Hosting / egress bill |
audit-llm-security | Unbounded consumption as an attack |
Propose: per-user daily token cap + hard daily-spend kill switch on
lib/ai.ts. Risk: public/api/chatcan replay a 50K context until the bill dies; RPM-only does not count. Keep-working: summarizer path already setsmax_tokens. Phase: Phase 1 — caps & kill switch.
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 output-token cap, 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.
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.
max_tokens (Anthropic),
max_completion_tokens or max_output_tokens (OpenAI); bound worst-case
cost; truncate RAG context.stream_options.include_usage; Anthropic sends it in message_start and
cumulative message_delta events.plan-input-validation.plan-llm-cost-guardrails.md, then end the turn with a standalone recap in chat: the two or three highest-impact findings and the first phase to approve. The file is the deliverable — write it before the recap.plan-input-validation.audit-langfuse-llm; unauth AI input → plan-input-validationplan-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.
plan-error-handling (visibility) and
audit-langfuse-llm (quality); this owns bounded spend.audit-llm-security — LLM10 unbounded consumption is the attack-shaped twin.audit-infra-cost — hosting/egress, not tokens.backend-patterns, audit-langfuse-llm, backend-observability.Plan at high effort. Execute after approval at the default effort under
approved-plan-execution.mdc(no reward hacking, no feature deletion).
What SKILL.md sets; muted values are Claude Code's defaults
highThree short reads, in order
llm-cost, token-budget, rate-limiting, cost-guardrails, abuse-prevention
162 skills in this plugin
/audit-accessibilityWCAG 2.2 AA audit via playwright-cli: axe-core, keyboard, contrast, target size, focus, ARIA. Use when "audit accessibility", "check a11y", "WCAG audit", "check keyboard nav", or "test screen reader".
/audit-agent-speedMeasure and fix a slow coding-agent setup: status line, hooks, instruction bloat, effort, worktree pile-up, antivirus and indexer scans. Use when "Claude is slow" or "CPU is pinned". App speed → audit-performance.
/audit-analyticsRead-only audit of product-analytics events (PostHog, Amplitude, Mixpanel, GA4): taxonomy, funnels, consent-gated firing, dead or duplicate events. Use when "audit our analytics", "are we tracking the right events", or "funnel instrumentation".
/audit-auth-flowsRead-only audit of app-layer auth: route×gate matrix, session lifecycle, OAuth, provider traps (getSession vs getUser, middleware-only gates, CVE-2025-29927). Use when "audit our auth" or "check middleware protection". RLS → plan-rls-audit.
/audit-backend-architectureRead-only backend-architecture audit and pattern advisor, gated by stack. Use when "audit backend architecture", "which pattern should I use", "am I over-engineering", or "sync vs event-driven". Enforced boundaries → enhance-arch-boundaries.
/audit-bundle-sizeAnalyse and shrink a web app's JavaScript bundle. Use when "reduce bundle size", "code splitting", "slow initial load", or "why is the bundle so big". Runtime → audit-performance.
npx claudepluginhub kensaurus/skills --plugin kenjiOther plugins' skills for the same job