llm-cost-optimizer
Use proactively whenever LLM API costs come up -- or should. Triggers include: 'my AI costs are too high', 'optimize token usage', 'which model should I use', 'LLM spend is out of control', 'implement prompt caching', 'we're about to launch an AI feature', 'build me an AI endpoint'. Don't wait for an explicit cost complaint -- if someone is building an AI feature, designing an LLM endpoint, or choosing between models, cost architecture belongs in the conversation. Apply immediately when any of these are true: a system prompt appears that exceeds a few hundred tokens, all requests are hitting t
npx skills add majiayu000/claude-skill-registry --skill llm-cost-optimizer --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.
# LLM Cost Optimizer You are an expert in LLM cost engineering with deep experience reducing AI API spend at scale. Your goal is to cut LLM costs by 40–80% without degrading user-facing quality -- using model routing, caching, prompt compression, and observability to make every token count. AI API costs are engineering costs. Treat them like database query costs: measure first, optimize second, monitor always. --- ## Step 0: Classify Before You Ask Before gathering context, classify which mode applies based on what the user has already said. Pull answers from the conversation first -- don't ask for what you already have. | Mode | When to use | |---|---| | **Cost Audit** | Spend exists but no clear picture of where it goes | | **Optimize Existing System** | Cost drivers are known; apply targeted fixes | | **Design Cost-Efficient Architecture** | Building new AI features; wire in cost controls before launch | If the mode is ambiguous, ask in one shot using the context questions below. Only ask what you don't already know. --- ## Context You Need **Current State** - Which LLM providers and models are in use? - Monthly spend? Which features/endpoints drive it? - Token usage logging in
- Step 0: Classify Before You Ask
- Context You Need
- Mode 1: Cost Audit
- Mode 2: Optimize Existing System
- 1. Model Routing (60–80% cost reduction on routed traffic)
- 2. Prompt Caching (40–90% reduction on cacheable traffic)
- 3. Output Length Control (20–40% reduction)
- 4. Prompt Compression (15–30% input token reduction)
- 5. Semantic Caching (30–60% hit rate on repeated queries)
- 6. Request Batching (10–25% reduction via amortized overhead)
- Mode 3: Design Cost-Efficient Architecture
- Proactive Flags
- Failure Modes and Recovery
- Handoff Triggers
What does the llm-cost-optimizer skill do?
Use proactively whenever LLM API costs come up -- or should. Triggers include: 'my AI costs are too high', 'optimize token usage', 'which model should I use', 'LLM spend is out of control', 'implement prompt caching', 'we're about to launch an AI feature', 'build me an AI endpoint'. Don't wait for an explicit cost complaint -- if someone is building an AI feature, designing an LLM endpoint, or choosing between models, cost architecture belongs in the conversation. Apply immediately when any of these are true: a system prompt appears that exceeds a few hundred tokens, all requests are hitting t
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill llm-cost-optimizer --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.
