cost-latency-optimizer
Reduces LLM costs and improves response times through caching, model selection, batching, and prompt optimization. Provides cost breakdowns, latency hotspots, and configuration recommendations. Use for "cost reduction", "performance optimization", "latency improvement", or "efficiency".
npx skills add majiayu000/claude-skill-registry --skill cost-latency-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.
# Cost & Latency Optimizer Optimize LLM applications for cost and performance. ## Cost Breakdown Analysis ```python class CostAnalyzer: def __init__(self): self.costs = { "llm_calls": 0, "embeddings": 0, "tool_calls": 0, } self.counts = { "llm_calls": 0, "embeddings": 0, } def track_llm_call(self, tokens_in: int, tokens_out: int): # GPT-4 pricing cost = (tokens_in / 1000) * 0.03 + (tokens_out / 1000) * 0.06 self.costs["llm_calls"] += cost self.counts["llm_calls"] += 1 def report(self): return { "total_cost": sum(self.costs.values()), "breakdown": self.costs, "avg_cost_per_call": self.costs["llm_calls"] / self.counts["llm_calls"], } ``` ## Caching Strategy ```python import hashlib from functools import lru_cache class LLMCache: def __init__(self, redis_client): self.cache = redis_client self.ttl = 3600 # 1 hour def get_cache_key(self, prompt: str, model: str) -> str: content = f"{model}:{prompt}" return f"llm_cache:{hashlib.sha256(content.encode()).hexdigest()}" def get(self, prompt: str, model: str): key = self.get_cache_key(prompt, model) return self.cache.get(key) def set(self, prompt: str, model: str, response: str): key = self.get_cache_key(prompt, model) self.cache.setex(key,
- Cost Breakdown Analysis
- Caching Strategy
- Model Selection
- Prompt Optimization
- Batching
- Latency Hotspot Analysis
- Optimization Recommendations
- Streaming for Faster TTFB
- Best Practices
- Output Checklist
What does the cost-latency-optimizer skill do?
Reduces LLM costs and improves response times through caching, model selection, batching, and prompt optimization. Provides cost breakdowns, latency hotspots, and configuration recommendations. Use for "cost reduction", "performance optimization", "latency improvement", or "efficiency".
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill cost-latency-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.
