cost-optimize

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cost Optimize

成本优化

Analyze recent token usage across agents and models, identify waste, and recommend specific optimizations with estimated dollar savings.
分析各Agent和模型近期的令牌使用情况,识别浪费点,并提供带有预估美元节省金额的具体优化建议。

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.
当成本超出预期,或者您希望主动降低支出时使用。分析内容包括模型选择效率、缓存利用率、Agent冗余度以及提示词效率。

Steps

步骤

  1. Load usage data -- call
    mcp__claude-flow__agentdb_hierarchical-recall
    to fetch recent token usage records from
    cost-tracking
    namespace (last 7 days)
  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 patterns -- call
    mcp__claude-flow__agentdb_pattern-search
    for previously successful optimizations
  7. Store recommendations -- call
    mcp__claude-flow__agentdb_pattern-store
    to record optimization recommendations in
    cost-patterns
    namespace
  8. Report -- display: ranked recommendations with savings estimate, total potential savings, implementation priority (quick wins first)
  1. 加载使用数据 —— 调用
    mcp__claude-flow__agentdb_hierarchical-recall
    cost-tracking
    命名空间获取最近7天的令牌使用记录
  2. 分析模型适配性 —— 针对每个Agent,评估模型层级是否匹配任务复杂度:
    • 执行简单任务(格式化、代码检查)的Agent使用Sonnet/Opus -> 建议改用Haiku或Agent Booster
    • 执行复杂任务(架构设计、安全检测)的Agent使用Haiku -> 标记质量风险
  3. 检查缓存率 —— 计算每个Agent的缓存命中率;若低于60%,建议启用或改进提示词缓存(缓存读取可降低90%的成本)
  4. 检测冗余性 —— 查找执行重叠任务的多个Agent,或者可批量处理却单独生成Agent的情况
  5. 预估节省金额 —— 针对每项建议,计算:当前成本、优化后的预计成本、美元节省金额、成本降低百分比
  6. 搜索优化模式 —— 调用
    mcp__claude-flow__agentdb_pattern-search
    查找过往成功的优化方案
  7. 存储建议 —— 调用
    mcp__claude-flow__agentdb_pattern-store
    将优化建议记录到
    cost-patterns
    命名空间
  8. 生成报告 —— 展示:按节省金额排序的建议、潜在总节省金额、实施优先级(优先快速见效的方案)

CLI alternative

CLI替代方案

bash
npx @claude-flow/cli@latest memory search --query "cost optimization strategies" --namespace cost-patterns
bash
npx @claude-flow/cli@latest memory search --query "cost optimization strategies" --namespace cost-patterns