
Cost Optimize
- 654 installs
- 67k repo stars
- Updated August 4, 2026
- ruvnet/ruflo
cost-optimize is a Claude Flow skill that analyzes token usage across agents and models, identifies waste, and recommends specific optimizations with estimated dollar savings for developers who run Claude, Cursor, or cus
About
cost-optimize is a RuFlo Claude Flow skill that analyzes recent token usage across agents and models, identifies waste, and recommends specific optimizations with estimated dollar savings. It connects to claude-flow memory and AgentDB pattern tools—memory_search, memory_list, memory_store, agentdb_pattern-search, agentdb_pattern-store, agentdb_semantic-route, and hooks_model-outcome—to inspect model selection efficiency and recurring spend patterns. Developers reach for cost-optimize when API bills exceed expectations or when proactively tuning agent stacks before scale. The skill targets model routing inefficiencies and redundant context rather than generic budgeting advice. It fits Claude Code agent workflows that already use claude-flow MCP hooks and want actionable, savings-backed recommendations instead of manual log review.
- Scans agent runs for high-cost patterns and suggests optimizations
- Generates cost reports with per-step token breakdowns
- Recommends cheaper model swaps or prompt compression tactics
- Works with any LLM-powered agent or MCP server
- Includes 12-step cost-optimization checklist
Cost Optimize by the numbers
- 654 all-time installs (skills.sh)
- +6 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #1,494 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/ruvnet/ruflo --skill cost-optimizeAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 654 |
|---|---|
| repo stars | ★ 67k |
| Last updated | August 4, 2026 |
| Repository | ruvnet/ruflo ↗ |
How do you reduce Claude agent token costs?
Automatically analyze and reduce token usage and API costs inside Claude, Cursor, and custom agent workflows.
Who is it for?
Developers operating Claude Flow or multi-model agent stacks who need data-backed token and API cost reductions.
Skip if: Developers with negligible LLM spend or teams not using claude-flow memory, AgentDB, or hooks_model-outcome telemetry.
When should I use this skill?
Token or API costs are higher than expected, or the user asks to proactively optimize agent spending.
What you get
Cost optimization report, waste findings, model-selection recommendations, and estimated dollar savings.
- cost optimization recommendations
- estimated savings report
By the numbers
- Uses 7 claude-flow MCP tools including memory_search, agentdb_pattern-search, and hooks_model-outcome
Files
Cost Optimize
Analyze recent token usage across agents and models, identify waste, and recommend specific optimizations with estimated dollar savings.
When to use
When costs are higher than expected or you want to proactively reduce spending. Analyzes model selection efficiency, cache utilization, agent redundancy, and prompt efficiency.
Steps
1. Load usage data -- call mcp__claude-flow__memory_search on the cost-tracking namespace (last 7 days). The memory_* tools route by namespace; use them — not agentdb_hierarchical-* (which routes by tier). 2. Analyze model fit -- for each agent, assess whether the model tier matches task complexity:
- Agents doing simple tasks (formatting, linting) on Sonnet/Opus → suggest Haiku or Agent Booster
- Agents doing complex tasks (architecture, security) on Haiku → flag quality risk
3. Check cache rates -- compute cache hit rate per agent; if below 60%, recommend enabling or improving prompt caching (90% cost reduction on cache reads) 4. Detect redundancy -- look for multiple agents performing overlapping tasks, or agents being spawned for work that could be batched 5. Estimate savings -- for each recommendation, calculate: current cost, projected cost after optimization, dollar savings, percentage reduction 6. Search prior optimization patterns -- call mcp__claude-flow__agentdb_pattern-search (ReasoningBank-routed; don't pass a namespace argument — pattern- tools ignore it). 7. Store the optimization pattern* -- two paths:
- Pattern store (typed, recommended):
mcp__claude-flow__agentdb_pattern-storewithtype: 'cost-optimization'. Don't pass anamespacearg — ReasoningBank routes it; on bridge unavailability the fallback writes to the reservedpatternnamespace withcontroller: 'memory-store-fallback'(see ruflo-agentdb ADR-0001). - Plain store (namespace-routable):
mcp__claude-flow__memory_store --namespace cost-patterns— this DOES respect thecost-patternsnamespace becausememory_*is namespace-routed.
8. Close the routing feedback loop — auto-emit `hooks_model-outcome` -- for each downgrade recommendation, format the outcome-emit command as part of the recommendation table so it can be run directly:
# success path (downgrade worked)
node plugins/ruflo-cost-tracker/scripts/outcome.mjs "<task-description>" <model> success
# escalated path (had to upgrade after downgrade attempt)
node plugins/ruflo-cost-tracker/scripts/outcome.mjs "<task-description>" <model> escalatedThe script wraps npx @claude-flow/cli hooks model-outcome -t ... -m ... -o ... with explicit-argv spawnSync so quoting is safe. Without this signal the router does not learn from cost-tracker's recommendations and the booster bypass rate (see cost-booster-route skill) does not improve over time. This is the typed equivalent of the legacy routing-outcomes namespace (see ruflo-intelligence ADR-0001 §"Neutral"). 9. Report -- display: ranked recommendations with savings estimate, total potential savings, implementation priority (quick wins first), and any model-outcome events emitted in step 8
CLI alternative
npx @claude-flow/cli@latest memory search --query "cost optimization strategies" --namespace cost-patterns
npx @claude-flow/cli@latest memory store --key "opt-2026-05-04" --value '{...}' --namespace cost-patternsRelated skills
How it compares
Pick cost-optimize over manual billing dashboards when claude-flow agent telemetry and pattern stores should drive actionable model-routing fixes.
FAQ
What does cost-optimize analyze?
cost-optimize reviews recent token usage across agents and models through claude-flow memory and AgentDB pattern tools. It identifies waste in model selection and routing, then recommends specific changes with estimated dollar savings.
When should developers run cost-optimize?
cost-optimize fits when API costs exceed expectations or before scaling agent workloads. The skill proactively inspects model efficiency and recurring spend patterns instead of offering generic budgeting guidance.