← 返回 Skills 市场
nextfrontierbuilds

Anthropic Cost Optimizer

作者 Next Frontier AI · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
107
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install anthropic-cost-optimizer
功能描述
Audits and rewrites your OpenClaw config to minimize API token costs. Use this skill whenever the user mentions high bills, API costs, billing changes, "too...
使用说明 (SKILL.md)

OpenClaw Cost Optimizer

Analyzes the user's OpenClaw config and rewrites it to minimize Anthropic API spend. Works on YAML and JSON configs. Reads pricing tables from references/pricing.md before starting.

Step 0 — Load pricing reference

Read references/pricing.md now. It contains current model rates and the savings formulas used for estimates. Do this before any analysis.

Step 1 — Locate the config

Check these locations in order, stop at the first match:

  1. Path the user explicitly provides
  2. ./openclaw.yaml or ./openclaw.json in the current working directory
  3. ~/.openclaw/config.yaml
  4. ~/.openclaw/openclaw.yaml
  5. ~/openclaw.yaml

If none found, ask the user to paste their config directly.

Step 2 — Audit: the five cost levers

Work through every lever. Flag each issue with severity HIGH / MEDIUM / LOW.

Lever 1 — Prompt caching (HIGH impact, ~60–90% input cost reduction)

Flag HIGH if any of these are missing for Anthropic models:

  • cacheRetention not set, or set to "none"

Fix: Add cacheRetention: "long" for the primary model. Use "short" (5 min) for agents that handle fast-changing context, "long" (1 hr) for everything else.

agents:
  defaults:
    models:
      anthropic/claude-opus-4-6:
        params:
          cacheRetention: "long"

Note: caching is API-key only. Subscription setup-tokens do not honor it.


Lever 2 — Model routing (HIGH impact)

Flag HIGH if: a single model (especially Opus) is used for ALL agents with no per-agent overrides.

Fix: Route by task complexity:

Agent type Recommended model
Main reasoning / planning anthropic/claude-opus-4-6
Coding, editing, review anthropic/claude-sonnet-4-6
Linting, search, triage, classify anthropic/claude-haiku-4-5
agents:
  list:
    - id: planner
      params:
        model: anthropic/claude-opus-4-6
    - id: coder
      params:
        model: anthropic/claude-sonnet-4-6
    - id: reviewer
      params:
        model: anthropic/claude-sonnet-4-6
    - id: triage
      params:
        model: anthropic/claude-haiku-4-5

Lever 3 — Thinking level (MEDIUM impact)

Flag MEDIUM if: thinking: "adaptive" or thinking: "high" is set as the default for ALL agents, including simple ones.

Fix: Scope thinking: "adaptive" only to the primary reasoning agent. Set thinking: "low" or omit for utility agents.

agents:
  defaults:
    models:
      anthropic/claude-opus-4-6:
        params:
          thinking: "low"   # default: low
  list:
    - id: planner
      params:
        thinking: "adaptive"  # override only where needed

Lever 4 — 1M context window (MEDIUM impact)

Flag MEDIUM if: context1m: true is set globally or for agents that don't need it.

The 1M context beta header triggers surcharge pricing for Anthropic API calls. Most agents don't need it.

Fix: Remove context1m: true from the global defaults. Re-add only to agents that demonstrably require >200K tokens of context.


Lever 5 — Fast mode (LOW impact, but easy win)

Flag LOW if: fastMode is not enabled for Sonnet agents doing quick tasks.

Fix: Add fastMode: true to Sonnet model params for agents doing rapid back-and-forth tasks (search, triage, review). This reduces latency and can lower costs on high-frequency agents.

models:
  anthropic/claude-sonnet-4-6:
    params:
      fastMode: true
      cacheRetention: "long"

Step 3 — Generate the optimized config

Rewrite the full config applying all fixes. Preserve every key the user had that is not being changed. Add comments above each changed block explaining what changed and why.

Format:

# COST OPTIMIZER — changed blocks annotated below
# Original: \x3Cwhat it was>  →  Optimized: \x3Cwhat it is now>

Step 4 — Show the diff and cost estimate

Before writing anything, show the user:

  1. Issues found — list each one with severity and one-line description
  2. Estimated monthly savings — use the formula from references/pricing.md with assumed 500K tokens/day baseline
  3. Diff — show only the changed blocks (not the full file unless it's short)

Example output format:

Issues found (3):
  [HIGH]   No prompt caching — estimated +$340/mo at current usage
  [HIGH]   All agents using Opus — Haiku suitable for triage/review agents
  [MEDIUM] thinking: adaptive set globally — limits to reasoning agent only

Estimated savings: ~$290/mo (68% reduction)
  Before: ~$430/mo  →  After: ~$140/mo

Changed blocks:
  + agents.defaults.models.anthropic/claude-opus-4-6.params.cacheRetention: "long"
  + agents.list[triage].params.model: anthropic/claude-haiku-4-5
  ~ agents.list[planner].params.thinking: adaptive → low (default); kept adaptive on planner only

Step 5 — Confirm and write

Ask the user: "Apply these changes to your config?"

  • If yes: write the optimized config back to the same file path. Then tell the user to run openclaw gateway restart (or it will auto-restart if config watch is enabled).
  • If no / partial: apply only confirmed changes.
  • If they want to review first: show the full optimized YAML before writing.

Edge cases

  • Subscription setup-token auth: Note that cacheRetention has no effect with subscription tokens — it's API-key only. Tell the user if their auth config uses sk-ant-oat-* tokens.
  • Multiple agents with no IDs: If the config has unnamed agents, suggest adding IDs to enable per-agent model routing.
  • Non-Anthropic providers: Only audit Anthropic model blocks. Leave OpenAI, Gemini, and other provider blocks untouched.
  • Config not found: If no config file is found and no paste provided, offer to generate a fresh cost-optimized starter config instead.
安全使用建议
This skill appears to do what it claims, but you should: (1) back up your OpenClaw config before running it, (2) review the reported issues, estimated savings, and the exact diff it proposes before approving any write, (3) be aware caching suggestions may require API-key usage (subscriptions/setup-tokens may not honor caching), and (4) only allow the skill to run with a user who understands and can validate the changes. Because the skill will read and (with confirmation) write files in your home/project paths, treat it like any tool that edits configuration — inspect outputs and keep a copy of the original config.
功能分析
Type: OpenClaw Skill Name: anthropic-cost-optimizer Version: 1.0.0 The 'anthropic-cost-optimizer' skill bundle is designed to audit and rewrite OpenClaw configuration files (e.g., ~/.openclaw/config.yaml and openclaw.json) to reduce API costs. While the stated purpose is legitimate and the instructions in SKILL.md include safety measures like diff previews and user confirmation, the skill requires high-privilege access to sensitive files containing API keys and authentication tokens. Furthermore, the instructions use a fictional 'critical context' regarding a future billing change in 2026 to create urgency and influence the agent's behavior, which is a form of prompt manipulation. These risky capabilities, combined with the sensitive nature of the targeted files, warrant a suspicious classification.
能力评估
Purpose & Capability
Name/description match the behavior: the skill inspects OpenClaw YAML/JSON, applies cost-focused edits (caching, model routing, thinking scope, context1m, fastMode) and estimates savings using a local pricing reference. It does not request unrelated secrets or binaries.
Instruction Scope
Instructions explicitly direct the agent to locate and read OpenClaw config files from the current directory and several home paths, analyze them using the bundled pricing reference, present a diff and cost estimate, then (with user confirmation) write the optimized config back to the same file. This is within the stated purpose but involves reading and modifying user files — the skill does ask for confirmation before writing, which mitigates risk, but users should review diffs and back up configs before applying changes.
Install Mechanism
No install spec and no code files — instruction-only skill. Lowest risk from installation because nothing is downloaded or installed on disk beyond the agent's normal execution environment.
Credentials
No environment variables, credentials, or external config paths are requested. The skill mentions that caching is API-key only, but it does not request API keys itself — this is consistent (it can only recommend config changes; applying caching may require the user to use API keys).
Persistence & Privilege
Skill is user-invocable and not forced-always; model invocation is allowed (normal default). Because it can write to local config files (with confirmation), consider that an agent with file-system access could apply changes. There's no evidence the skill modifies other skills or system-wide agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install anthropic-cost-optimizer
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /anthropic-cost-optimizer 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
anthropic-cost-optimizer 1.0.0 — initial release - Audits OpenClaw configuration for Anthropic API cost-saving opportunities. - Identifies and fixes issues in five main cost levers: prompt caching, model routing, thinking level, 1M context window, and fast mode. - Flags each issue by impact severity (HIGH, MEDIUM, LOW) and recommends targeted optimizations. - Generates annotated config diffs and estimates monthly savings before applying changes. - Handles YAML/JSON configs, edge cases, and provides clear user prompts for confirmation and next steps.
元数据
Slug anthropic-cost-optimizer
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Anthropic Cost Optimizer 是什么?

Audits and rewrites your OpenClaw config to minimize API token costs. Use this skill whenever the user mentions high bills, API costs, billing changes, "too... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 107 次。

如何安装 Anthropic Cost Optimizer?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install anthropic-cost-optimizer」即可一键安装,无需额外配置。

Anthropic Cost Optimizer 是免费的吗?

是的,Anthropic Cost Optimizer 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Anthropic Cost Optimizer 支持哪些平台?

Anthropic Cost Optimizer 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Anthropic Cost Optimizer?

由 Next Frontier AI(@nextfrontierbuilds)开发并维护,当前版本 v1.0.0。

💬 留言讨论