一键导入
cost-aware-pipeline
Cost optimization for LLM pipelines including model routing, prompt caching, token budgets, and retry logic for Claude API usage.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Cost optimization for LLM pipelines including model routing, prompt caching, token budgets, and retry logic for Claude API usage.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Unified design foundations — design system architecture, tokens, component specs, visual principles, creative vision, figma integration, plus brand design system loader (66 real brands via DESIGN.md). Absorbs design, design-system, design-systems, design-principles, design-router, creative-vision, figma, design-md.
Render, summarize, and present markdown documents and structured content in multiple output modes
Ultra UI skill - combines Google's DESIGN.md spec (machine-readable design tokens) with the ui-ux-pro-max knowledge base (91 styles, 161 palettes, 73 font pairings, 161 products, 104 UX guidelines, 25 chart types). Generates lint-clean DESIGN.md files, validates token references and WCAG contrast, exports Tailwind/DTCG tokens, and diffs design systems version-over-version.
Initialize UltraThink capabilities in the current project directory
Org-Bench Google-bipartite winning mechanism — the 4-section design-doc gate that every non-trivial change passes through. Use when the Director defines new work, when an Integrator reviews a lane (code/quality/devops), when the Director approves, or when a Worker is about to start coding and needs the spec. Tools live in the `design-doc` MCP server. Triggers on phrases like "design doc", "design review", "approve revision", "lane verdict", "what does this issue require", "is this approved yet".
Web scraping with anti-bot bypass (Cloudflare Turnstile etc.), stealth headless browsing, adaptive selectors, and concurrent crawls. Use when the user asks to scrape, crawl, or extract data from websites; the built-in WebFetch fails; the target has anti-bot protections; or the work needs JavaScript rendering. Prefers the registered MCP tools (mcp__scrapling__*) over raw Python so token cost stays low.
| name | cost-aware-pipeline |
| description | Cost optimization for LLM pipelines including model routing, prompt caching, token budgets, and retry logic for Claude API usage. |
| layer | utility |
| category | optimization |
| triggers | ["cost optimization","model routing","llm pipeline","token cost","api cost","prompt caching","model selection","cost tracking"] |
| linksTo | ["context-budget","autonomous-loops","ai-agents","claude-api"] |
| riskLevel | low |
Optimize cost, latency, and quality across LLM pipelines.
Route tasks to the cheapest model that meets quality requirements.
| Task Type | Model | Why | Cost/MTok (input) |
|---|---|---|---|
| Classification, extraction | Haiku | Fast, cheap, sufficient | $0.25 |
| Summarization, simple Q&A | Haiku | Good enough quality | $0.25 |
| Code generation, refactoring | Sonnet | Best code quality/cost ratio | $3.00 |
| Code review, debugging | Sonnet | Solid reasoning for code | $3.00 |
| Architecture, planning | Opus | Deep reasoning needed | $15.00 |
| Complex analysis, research | Opus | Multi-step reasoning | $15.00 |
| Safety-critical decisions | Opus | Highest reliability | $15.00 |
UltraThink note: Per user preference — Opus for thinking/planning, Sonnet for coding/implementing. No Haiku for user-facing tasks (Haiku only for internal pipeline stages).
if task.requires_deep_reasoning:
model = "opus"
elif task.is_code or task.is_implementation:
model = "sonnet"
elif task.is_simple_extraction or task.is_classification:
model = "haiku"
else:
model = "sonnet" # safe default
Cache static context to reduce costs on repeated calls.
# Mark cache breakpoints in API calls
system_prompt = [
{"type": "text", "text": static_instructions, "cache_control": {"type": "ephemeral"}},
{"type": "text", "text": dynamic_context}
]
Cache pricing (Claude):
max_tokens_by_task = {
"classification": 100,
"extraction": 500,
"code_generation": 4000,
"analysis": 2000,
"planning": 3000,
}
class BudgetTracker:
def __init__(self, max_cost_usd: float):
self.max_cost = max_cost_usd
self.spent = 0.0
def can_proceed(self, estimated_cost: float) -> bool:
return self.spent + estimated_cost <= self.max_cost
def record(self, input_tokens: int, output_tokens: int, model: str):
self.spent += calculate_cost(input_tokens, output_tokens, model)
estimated_cost = (input_tokens × input_price + output_tokens × output_price) / 1_000_000
Only retry on transient errors. Never retry on:
retryable_errors = [429, 500, 502, 503, 529]
for attempt in range(max_retries):
try:
response = call_api(...)
break
except APIError as e:
if e.status not in retryable_errors:
raise # Don't retry non-transient errors
wait = min(base_delay * (2 ** attempt), max_delay)
sleep(wait + random_jitter)
| Model | Input/MTok | Output/MTok | Context |
|---|---|---|---|
| Haiku 3.5 | $0.80 | $4.00 | 200K |
| Sonnet 4 | $3.00 | $15.00 | 200K |
| Opus 4 | $15.00 | $75.00 | 200K |
Extended thinking multiplies output cost. Prompt caching reduces input cost by up to 90%.
Try Haiku first. If confidence < threshold, escalate to Sonnet. If still uncertain, escalate to Opus. Saves: 60-80% on tasks where Haiku suffices.
Run N Haiku calls in parallel, merge results with one Sonnet call. Saves: Avoids one expensive call for embarrassingly parallel tasks.
Generate with Sonnet, review with Opus. Fix with Sonnet. Repeat until Opus approves. Saves: Opus only reads, never generates (output tokens are 5× more expensive).
autonomous-loops to set cost budgets on loop patternscontext-budget to audit where tokens are being consumed