skills/cost-optimizer/SKILL.md
Tracks cumulative LLM costs across DAG execution and makes real-time decisions to stay within budget. Downgrades models, skips optional nodes, or stops early when cost exceeds thresholds. Use when managing execution budgets, analyzing cost breakdowns, or optimizing model routing for cost. Activate on "cost budget", "too expensive", "reduce cost", "cost optimization", "model downgrade", "budget exceeded". NOT for LLM model selection logic (use llm-router), pricing comparisons across providers, or billing/invoicing.
npx skillsauth add curiositech/windags-skills cost-optimizerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Tracks cumulative LLM costs across DAG execution and makes real-time decisions to stay within budget: downgrade models, skip optional nodes, or stop early.
✅ Use for:
❌ NOT for:
llm-router)flowchart TD
N[Node about to execute] --> C[Check: spent + estimated_node_cost vs budget]
C --> S{Within budget?}
S -->|Yes, >20% remaining| E[Execute at planned model tier]
S -->|Yes, <20% remaining| W[Execute but downgrade to Tier 1 if possible]
S -->|No| D{Node optional?}
D -->|Yes| SK[Skip node]
D -->|No| H{Human gate available?}
H -->|Yes| A[Ask human: continue over budget?]
H -->|No| ST[Stop execution, return partial results]
| Budget Remaining | Action | |-----------------|--------| | >50% | Execute at planned model tier | | 20-50% | Log warning. Continue at planned tier. | | 10-20% | Downgrade remaining Tier 2 nodes to Tier 1 (Haiku) | | 5-10% | Downgrade ALL remaining nodes to Tier 1. Skip optional nodes. | | <5% | Stop execution unless next node is critical path | | 0% | Stop. Return partial results with cost breakdown. |
Before each node executes, estimate its cost:
estimated_cost = (avg_input_tokens × input_price + avg_output_tokens × output_price)
Use historical averages for this skill + model combination. If no history, use defaults:
cost_report:
total_budget: 0.50
total_spent: 0.37
budget_remaining: 0.13
nodes_executed: 8
nodes_skipped: 1
nodes_downgraded: 2
model_breakdown:
haiku: { calls: 4, cost: 0.004 }
sonnet: { calls: 3, cost: 0.036 }
opus: { calls: 1, cost: 0.33 }
savings_recommendations:
- "Node 'deep-analysis' used Opus ($0.33) but downstream accepted on first try. Try Sonnet next time — potential saving: $0.32"
- "Nodes 'validate-a' and 'validate-b' are sequential but independent. Parallelize to reduce wall-clock time."
Wrong: Running DAGs without any cost tracking until the API bill arrives. Right: Every DAG execution has a budget, even if generous. Track spend per node.
Wrong: Downgrading Opus nodes to Haiku at 50% budget remaining, causing quality failures that trigger expensive retries. Right: Only downgrade when the alternative is stopping execution. Retries cost more than the original model tier.
Wrong: Budgeting for one attempt per node. Right: Budget for avg_retries × cost_per_attempt. A node with 3 retries on Sonnet costs $0.036, not $0.012.
This skill produces:
tools
Building resilient distributed systems with circuit breakers, retries with full-jitter exponential backoff, retry budgets (per-request 3-attempt + per-client 10% ratio per Google SRE), deadline propagation, and the cascading-failure math (4 layers × 3 retries = 64x amplification). Grounded in Resilience4j, Microsoft Cloud Patterns, AWS Architecture Blog (Marc Brooker), and Google SRE Book.
testing
Designing HTTP cache headers that work correctly across browsers, CDNs, and shared proxies — `Cache-Control` directives per RFC 9111, `stale-while-revalidate` and `stale-if-error` per RFC 5861, the Vary header for varying responses, and surrogate keys for tag-based purging. Grounded in IETF RFCs and Cloudflare/Fastly docs.
development
Use when designing or fixing a Content Security Policy on a real site, choosing between nonce-based and hash-based CSP, adding strict-dynamic, debugging "Refused to execute inline script" errors, deploying CSP in report-only mode first, configuring report-to / report-uri, or auditing an existing policy for unsafe-inline / unsafe-eval / wildcards. Triggers: "CSP blocks legitimate inline script", strict-dynamic, nonce-{RANDOM}, sha256-{HASH}, object-src none, base-uri none, frame-ancestors, Trusted Types, X-Content-Security-Policy obsolete, report-only vs enforced. NOT for general HTTP security headers (HSTS, COOP/COEP), Trusted Types deep dive, CORS configuration, or building a WAF.
tools
Choosing and operating an HTTP API versioning strategy that doesn't break clients — Stripe's date-based pinned versions, the Deprecation/Sunset header pair (RFC 9745 + RFC 8594), URI vs header vs media-type approaches, and the version-transformer pattern. Grounded in Stripe's published architecture and IETF RFCs.