ai-cost-optimizer
Skill3 starsChanged 4 months agoMITView on GitHub
Optimize LLM inference costs: token budget allocation, model routing, caching strategy, and batching without breaching quality thresholds. Use when working on prompt engineering, AI workflows, agents, context design, or LLM optimization.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- ScientiaCapital/model-finopstheir own version, first seen Jul 12, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- ScientiaCapital/model-finops★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository59 other files it gives its agents.
- agent-memory-designerSkill
- ai-evaluation-builderSkill
- ai-latency-optimizerSkill
- ai-solution-architectSkill
- ai-workflow-builderSkill
- context-engineeringSkill
- human-in-the-loop-designerSkill
- multi-agent-plannerSkill
- prompt-engineerSkill
- prompt-optimizerSkill
- prompt-reviewerSkill
- adr-generatorSkill
- api-designerSkill
- architecture-reviewSkill
- component-diagram-builderSkill
- container-diagram-builderSkill
- data-flow-analyzerSkill
- integration-plannerSkill
- observability-plannerSkill
- scalability-advisorSkill
- solution-architectureSkill
- system-context-builderSkill
- experiment-designerSkill
- go-to-market-plannerSkill
- pricing-strategy-advisorSkill
- mcp-best-practicesSkill
- mcp-client-generatorSkill
- mcp-security-reviewSkill
- mcp-server-generatorSkill
- mcp-tool-generatorSkill
- acceptance-criteria-generatorSkill
- analytics-instrumentation-plannerSkill
- competitive-analysisSkill
- epic-generatorSkill
- feature-prioritizationSkill
- idea-validatorSkill
- north-star-metric-advisorSkill
- okr-builderSkill
- persona-generatorSkill
- prd-generatorSkill
- problem-statement-builderSkill
- product-discovery-assistantSkill
- product-vision-builderSkill
- sprint-plannerSkill
- story-mappingSkill
- user-story-generatorSkill
- value-proposition-designerSkill
- chunking-strategy-advisorSkill
- embedding-strategy-advisorSkill
- hybrid-search-advisorSkill
- knowledge-ingestion-plannerSkill
- rag-architecture-designerSkill
- retriever-optimizerSkill
- ai-governance-advisorSkill
- ai-threat-modelingSkill
- guardrails-builderSkill
- owasp-llm-reviewerSkill
- prompt-injection-detectorSkill
- skill-nameSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 74
Document cache hit rate target and monitoring.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Cost Optimizer
Purpose
Optimize LLM inference costs: token budget allocation, model routing, caching strategy, and batching without breaching quality thresholds.
Input: AI architecture or workflow spec, usage volume projections, quality thresholds, current cost baseline (optional)
Output: Cost Optimization Plan with savings estimates, trade-off analysis, and implementation priorities
Examples: See examples.md for worked input/output.
Workflow
Step 1: Establish cost baseline
| Component | Tokens/request (avg) | Cost/request | Monthly volume | Monthly cost |
| System prompt | ||||
| User context | ||||
| Model output | ||||
| Tool overhead |
Identify top 3 cost drivers by spend share.
Step 2: Audit token usage
Analyze per stage:
- Redundant context (duplicate documents, full history)
- Over-sized system prompts
- Verbose output formats
- Unnecessary model tier for task complexity
| Finding | Est. token waste | Fix category |
Step 3: Evaluate optimization levers
| Lever | Savings potential | Quality risk | Effort |
| Prompt compression | Medium | Low | Low |
| Context pruning / summarization | High | Medium | Medium |
| Model downgrade for simple tasks | High | Medium | Low |
| Semantic caching | High | Low | Medium |
| Batching (offline) | Medium | None | Low |
| Response length limits | Medium | Low | Low |
| Fine-tuning (replace long prompts) | High | Medium | High |
Step 4: Design model routing
Request → Classifier → [Simple path: small model] / [Complex path: frontier model]Define routing criteria with fallback when classifier uncertain.
Step 5: Plan caching layer
| Cache type | Key | TTL | Invalidation |
| Exact match | Hash(prompt) | 24h | Prompt version change |
| Semantic | Embedding similarity | 1h | Source doc update |
Document cache hit rate target and monitoring.
Step 6: Quantify savings and validate
Project monthly savings per lever. Confirm no quality metric drops below threshold from eval plan.
Run Validation checklist.
Decision Rules
| Condition | Action |
| No quality thresholds defined | Stop; request from ai-evaluation-builder or architect |
| Savings <5% for proposed change | Deprioritize; focus on top cost drivers |
| Model downgrade drops eval metric >2% | Reject downgrade; try prompt optimization first |
| Real-time use case | Skip batching; prioritize caching and routing |
| PII in cache keys | Use hashed keys; enforce TTL and encryption |
| Cost spike without volume change | Investigate prompt regression or model default change |
Validation
- Cost baseline with per-component breakdown
- Top 3 cost drivers identified
- ≥3 optimization levers evaluated with trade-offs
- Savings projected with assumptions stated
- Quality impact assessed against eval thresholds
- Model routing criteria defined (if applicable)
- Caching strategy with invalidation rules
- Implementation priority ranked by ROI
Anti-patterns
- Blind downgrade — switching to cheaper model without eval comparison.
- Cache without invalidation — serving stale answers after knowledge update.
- Token counting ignorance — optimizing output while input is 90% of cost.
- Premature fine-tuning — expensive training before prompt optimization exhausted.
- Hidden retry costs — aggressive retries multiplying spend silently.
Best Practices
- Measure cost per successful task, not per API call.
- Track token usage by workflow stage in production.
- A/B test cost optimizations against quality metrics.
- Set budget alerts at 80% and 100% of monthly cap.
- Pair with ai-latency-optimizer when both NFRs conflict.
Output Structure
# Cost Optimization Plan: [System Name]
## Baseline
| Component | Cost/request | Monthly | Share % |
|-----------|--------------|---------|---------|
## Findings
| Issue | Waste estimate | Recommended fix |
|-------|----------------|-----------------|
## Optimization Levers
| Lever | Est. savings | Quality risk | Priority |
|-------|--------------|--------------|----------|
## Model Routing
[Classifier criteria and model mapping]
## Caching Strategy
[Type, key, TTL, invalidation]
## Projected Savings
| Scenario | Monthly cost | vs baseline |
|----------|--------------|-------------|
## Implementation Roadmap
| Phase | Changes | Expected savings |
|-------|---------|------------------|Next Skills
| Outcome | Recommended Skill |
| Optimize latency (may conflict) | ai/ai-latency-optimizer |
| Compress prompts | ai/prompt-optimizer |
| Reduce context size | ai/context-engineering |
| Re-validate quality post-change | ai/ai-evaluation-builder |
| Architecture-level redesign | ai/ai-solution-architect |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

