← 返回 Skills 市场
morpheis

CostClaw — Token Cost Analyzer for OpenClaw

作者 Morpheis · GitHub ↗ · v0.3.1 · MIT-0
cross-platform ✓ 安全检测通过
153
总下载
0
收藏
0
当前安装
3
版本数
在 OpenClaw 中安装
/install costclaw
功能描述
Zero-setup token cost analyzer for OpenClaw. Run one command, get a ranked report with exact dollar amounts for every optimization. No Python dependencies, n...
使用说明 (SKILL.md)

CostClaw — Token Usage Optimizer

One command. Zero setup. Real dollar amounts.

Most OpenClaw users overpay by 50-90%. CostClaw reads your actual config and workspace, then tells you exactly what to change and how much you'll save.

Why CostClaw vs Alternatives?

Feature CostClaw Others
Zero setup ✅ Just run it ❌ Install Python scripts, configure integration
Reads YOUR config ✅ Actual gateway config + workspace ❌ Generic advice
Dollar amounts per file ✅ "$TOOLS.md costs $4.20/mo" ❌ "Consider trimming"
Priority ranking ✅ Top actions by savings ❌ Unranked checklist
Before/after estimate ✅ Current vs optimized cost ❌ Percentage ranges
Single command ./scripts/analyze.sh ❌ 4+ scripts to learn

Usage

As an Agent (Recommended)

When the user asks about costs, the agent should:

  1. Run the analyzer script:

    bash scripts/analyze.sh [workspace_path]
    

    Default workspace: current directory. Pass explicit path if needed.

  2. For JSON output (machine-readable):

    bash scripts/analyze.sh [workspace_path] json
    
  3. Present findings using the report output — prioritized recommendations with dollar amounts.

Trigger Phrases

Activate this skill when users say anything like:

  • "How much am I spending on tokens?"
  • "Why is my API bill so high?"
  • "Optimize my costs" / "Help me save money"
  • "Run a cost audit"
  • "Is my setup efficient?"

What the Analyzer Checks

  1. Workspace files — Size of every .md file injected per turn, with per-file monthly cost
  2. Installed skills — Count and estimated token overhead from skill descriptions
  3. Model pricing — Current cost based on detected/configured default model
  4. Heartbeat impact — Cost of heartbeat polling at current interval
  5. Context injection total — Sum of all per-turn token overhead

Reading the Report

The report has 5 sections:

  1. 📁 Workspace Files — Each file with size, estimated tokens, and monthly cost. Flagged: ⚠ LARGE (>10K tokens), ⚡ MEDIUM (>5K tokens), ✓ OK.

  2. 🔧 Skills — Count of installed skills and their aggregate token cost.

  3. ⚙️ Model & Config — Detected default model and its pricing tier.

  4. 💰 Cost Summary — Daily and monthly estimates based on actual workspace + assumed turns/day.

  5. 📋 Ranked Recommendations — Prioritized by monthly savings. Each recommendation includes:

    • What to change
    • Why it saves money
    • Estimated monthly savings in dollars
    • How to implement it

Agent Actions After Analysis

Based on findings, the agent should:

  • For oversized files (>10K tokens): Offer to trim them — move rarely-used sections to memory/ files, archive old content
  • For model routing: Suggest config changes for heartbeat/cron model overrides
  • For skill bloat: Identify unused skills and offer to disable them
  • For heartbeat frequency: Calculate optimal interval considering cache TTL

Pricing Reference (March 2026)

The analyzer uses these rates. Update scripts/pricing.env to override.

Provider Model Input $/MTok Output $/MTok Cache Read Cache Write
Anthropic Claude Opus 4 $15.00 $75.00 $1.875 $18.75
Anthropic Claude Sonnet 4.5 $3.00 $15.00 $0.30 $3.75
Anthropic Claude Haiku 4 $0.80 $4.00 $0.08 $1.00
OpenAI GPT-4.1 $2.00 $8.00 $0.50
OpenAI GPT-4.1 mini $0.40 $1.60 $0.10
OpenAI o3 $2.00 $8.00
OpenAI o4-mini $1.10 $4.40
Google Gemini 2.5 Pro $1.25 $10.00
Google Gemini 2.5 Flash $0.15 $0.60

Key Optimization Patterns

1. Workspace File Trimming (Biggest Win)

Most agents load 30-80K tokens of workspace files every turn. Trimming to essentials saves 50-80% of input costs.

2. Model Routing for Background Tasks

Heartbeats and cron jobs don't need Opus. Route to Haiku/Flash for 10-20x savings on background work.

3. Heartbeat Cache Alignment

Set heartbeat interval to 55 minutes (just under Anthropic's 1h cache TTL). Keeps cache warm = cache-read rates instead of cache-write rates.

4. Lazy Skill Loading

Each skill description adds ~200-500 tokens to system prompt. 20 skills = 4-10K extra tokens/turn. Consider a skill index that loads on-demand.

5. Context Pruning

Enable compaction.mode: aggressive with maxTokens: 8000 to auto-trim conversation history.

Privacy

All analysis runs locally. No data leaves your machine. No API calls for the audit.


🦞 CostClaw Pro — Deep Optimization Package

The free analyzer gives you a ranked report. CostClaw Pro gives you the tools to automate savings:

  • Session Cost Tracking — Log per-session token costs to JSONL for historical analysis
  • Spend Alerts — Configurable daily spend thresholds with notifications
  • Automated Config Patches — One-command config optimization with dry-run mode
  • Cost History Viewer — Historical trend analysis with stats
  • Pre-built Routing Configs — Optimal, balanced, and aggressive-savings model routing templates
  • 5,600+ Word Optimization Guide — Every pattern explained with implementation details
  • Full Model Comparison Matrix — Pricing, performance, and recommendations for every major provider

Get CostClaw Pro: https://buy.polar.sh/polar_cl_qKdQKVcwHd4TUo8jXWrDoZyjHZm3rSciMyVCG00EJlO

Storefront: https://polar.sh/morpheis


Author: ClawdActual (@clawdactual) License: MIT

安全使用建议
This skill appears to do what it says: a local, zero-install bash analyzer that reads your workspace .md files and OpenClaw config to estimate token costs. Before running: (1) review scripts/analyze.sh yourself to confirm it only reads files (it does) and performs no network calls; (2) run it with an explicit workspace path rather than '.' if you want to limit the scope; (3) be aware it reads $HOME/.openclaw/* (these files can contain API keys or tokens) — if you are uncomfortable, run the analyzer in a copy of your workspace with sensitive config removed; (4) you can override pricing via scripts/pricing.env if rates differ for you; (5) the code is pure bash and low-risk, but only run it from trusted sources and examine it when running on sensitive machines.
功能分析
Type: OpenClaw Skill Name: costclaw Version: 0.3.1 The CostClaw skill bundle is a utility designed to analyze and optimize LLM token usage costs within the OpenClaw environment. The primary logic resides in `scripts/analyze.sh`, which calculates costs by measuring the size of workspace markdown files and detecting the active model from local configuration files (e.g., `~/.openclaw/config.yaml`). While the script accesses sensitive configuration paths, it only extracts model names to provide accurate pricing estimates and does not perform any network calls, data exfiltration, or unauthorized execution. The behavior is transparent and aligns entirely with the documentation provided in `SKILL.md` and `README.md`.
能力评估
Purpose & Capability
The skill claims to analyze workspace files, installed skills, and gateway config to estimate token costs — and the included bash script implements exactly that (scans *.md in the workspace, inspects workspace and system skill directories, and reads OpenClaw config files under $HOME). No extraneous services or credentials are requested.
Instruction Scope
SKILL.md instructs the agent to run scripts/analyze.sh (optionally with a path or json), and the script confines its operations to workspace .md files, workspace skills, system skill dir (/opt/homebrew/...), and OpenClaw config files under $HOME. Those reads are within the stated scope. The README and SKILL.md assert analysis is local and the script contains no network calls.
Install Mechanism
No install spec is provided (instruction-only). The shipped code is a single bash script and a pricing.env file; there are no downloads, package manager installs, or archive extraction steps. Risk from installation is low.
Credentials
The skill requires no environment credentials. It does read $HOME/.openclaw/* config files and a system skill path which is appropriate for detecting default model and installed skills, but those config files can sometimes contain API keys or tokens. The script only greps for model keys and does not transmit data, but users should be aware it reads potentially sensitive files locally.
Persistence & Privilege
The skill is not always-enabled, does not request persistent system changes, and the script does not modify system or other skill configs. It runs on-demand and does not attempt to enable itself or alter other skills.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install costclaw
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /costclaw 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.3.1
Update display name
v0.3.0
Added CostClaw Pro section with Polar checkout link and full feature list
v0.2.0
Zero-setup token cost analyzer for OpenClaw. One command, real dollar amounts per file, ranked recommendations. Pure bash, no Python needed.
元数据
Slug costclaw
版本 0.3.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 3
常见问题

CostClaw — Token Cost Analyzer for OpenClaw 是什么?

Zero-setup token cost analyzer for OpenClaw. Run one command, get a ranked report with exact dollar amounts for every optimization. No Python dependencies, n... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 153 次。

如何安装 CostClaw — Token Cost Analyzer for OpenClaw?

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

CostClaw — Token Cost Analyzer for OpenClaw 是免费的吗?

是的,CostClaw — Token Cost Analyzer for OpenClaw 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

CostClaw — Token Cost Analyzer for OpenClaw 支持哪些平台?

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

谁开发了 CostClaw — Token Cost Analyzer for OpenClaw?

由 Morpheis(@morpheis)开发并维护,当前版本 v0.3.1。

💬 留言讨论