← 返回 Skills 市场
tujinsama

budget-analyzer-claw

作者 Ricky · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
101
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install budget-analyzer-claw
功能描述
预算分析虾 — OpenClaw 数字员工体系的财务守门员。实时监控所有 AI 资源支出,智能控制开销,防止产生意外的巨额费用。 当以下情况时使用此 Skill: (1) 用户询问今日/本周/本月花了多少钱 (2) 用户询问哪个数字员工最费钱、成本占比 (3) 用户要求分析成本趋势、优化建议 (4) 用户要求设置...
使用说明 (SKILL.md)

预算分析虾

核心职责

监控 OpenClaw 所有 agent 的资源消耗,计算实际成本,对比预算,检测异常,生成报告,推送预警。

配置文件

  • references/billing-rules.json — 各服务商计费标准(LLM token 单价、存储、计算)
  • references/budget-config.yaml — 预算上限和预警阈值配置
  • references/optimization-tips.md — 成本优化建议库(需要时读取)

工作流程

1. 获取消耗数据

使用 session_status 工具获取当前 session 的 token 用量,或通过 sessions_list 获取所有 session 的用量:

session_status → 返回当前 session 的 input/output tokens、model、cost
sessions_list  → 返回所有活跃 session 列表(含 agent 名称)

对每个 session 调用 session_status 获取详细用量,汇总为结构化数据:

[
  {"agent": "main", "model": "skyapi/claude-sonnet-4-6", "input_tokens": 5000, "output_tokens": 1200},
  {"agent": "pptclaw", "model": "skyapi/claude-sonnet-4-6", "input_tokens": 3000, "output_tokens": 800}
]

2. 计算成本

将汇总数据写入临时文件,调用脚本计算:

python3 ~/.openclaw/skills/budget-analyzer-claw/scripts/calculate-cost.py \
  --file /tmp/usage.json --budget 500

脚本读取 references/billing-rules.json 中的单价,输出各 agent 成本明细和总成本。

如果 billing-rules.json 中没有对应模型:提示用户更新计费规则,并基于已知数据给出估算。

3. 预算对比与预警

读取 references/budget-config.yaml 获取预算配置,计算使用率:

使用率 状态 行动
\x3C 50% ✅ 正常 仅报告
50-80% 🟡 注意 报告 + 提示关注
80-100% ⚠️ 预警 报告 + 建议措施
> 100% 🔴 超支 报告 + 建议暂停非紧急任务
> 150% 🚨 紧急 报告 + 强烈建议立即干预

4. 异常检测(可选)

当有历史数据时,运行异常检测:

python3 ~/.openclaw/skills/budget-analyzer-claw/scripts/detect-anomaly.py \
  --current \x3C今日成本> --history \x3C过去7天成本列表>

Z-score > 2 触发 WARNING,> 3 触发 CRITICAL。

5. 生成报告

根据用户需求生成对应粒度的报告:

日报格式

📊 今日成本报告(截至 HH:MM)

总成本:¥XX.XX / ¥500.00(预算)
使用率:XX% [状态图标]

分项明细:
• [agent名]:¥XX.XX(XX%)
...

💡 优化建议:[如有异常或高成本项,给出具体建议]

周报/月报:增加趋势描述、同比环比、Top 3 消耗大户、优化空间估算。

6. 优化建议

当成本偏高或用户主动询问时,读取 references/optimization-tips.md,结合实际数据给出针对性建议(模型降级、批量处理、缓存、存储清理等)。

数据来源说明

OpenClaw 目前通过 session_status 工具获取 token 用量。如需历史数据,可:

  1. 查询 sessions_list 获取近期 session 列表
  2. 对每个 session 调用 sessions_history 估算用量
  3. 用户也可手动提供成本数据(从服务商账单复制)

注意事项

  • 成本为估算值,以服务商实际账单为准
  • 计费规则需手动维护,建议每月对照官方文档更新 billing-rules.json
  • 自动暂停 agent 需用户明确授权,不可自行执行
  • 报告中的成本数据属于业务敏感信息,不在公开群聊中分享
安全使用建议
This skill appears to do what it says: collect session usage via the platform's session_* tools, compute costs with local pricing rules, detect anomalies, and prepare reports. Before installing: (1) confirm the platform session_status/sessions_list APIs it uses are expected and that you are comfortable the skill will read session usage data (this is necessary for cost reporting); (2) review/adjust references/billing-rules.json and usd_to_cny so currency/unit conversions match your real bills; (3) check references/budget-config.yaml channels/recipients so notifications don't go to unintended users and decide whether you want the skill to have authority to pause agents (the README says user authorization is required); (4) test the scripts with sample data to ensure model-name matching and unknown-model behavior are acceptable. No evidence of hidden network exfiltration or unrelated credential requests was found.
功能分析
Type: OpenClaw Skill Name: budget-analyzer-claw Version: 1.0.0 The budget-analyzer-claw skill is a legitimate utility for monitoring and managing AI resource costs. It uses Python scripts (calculate-cost.py and detect-anomaly.py) to process session usage data against user-defined billing rules and budget configurations. The instructions in SKILL.md are well-aligned with its stated purpose, including explicit safeguards against unauthorized actions (e.g., requiring user consent before pausing agents) and privacy considerations for sensitive financial data. No indicators of data exfiltration, malicious execution, or harmful prompt injection were detected.
能力评估
Purpose & Capability
Name/description (budget monitoring, alerts, reports) match the included scripts, references and SKILL.md. The code reads local billing rules, budget config and produces reports/alerts as documented. Required tools (session_status, sessions_list) are reasonable for gathering usage data.
Instruction Scope
Instructions are narrowly scoped to reading session usage (session_status/sessions_list/sessions_history), computing costs, checking budget-config and optionally running anomaly detection. This legitimately requires access to session usage data. Note: SKILL.md promises reporting and 'push pre-alerts' but contains no explicit delivery implementation; behavior that could pause agents is explicitly gated by user authorization in the docs (good).
Install Mechanism
No install spec and included scripts are small, plain Python files. Nothing is downloaded from external URLs or installed into system paths. This is low-risk.
Credentials
The skill declares no required environment variables or external credentials (appropriate). Minor concerns: currency handling and unit conventions mix USD and CNY — billing-rules.json lists USD unit prices and usd_to_cny conversion, while budget-config.yaml budgets are expressed in '元' (CNY). Make sure usd_to_cny is set correctly for your environment. Also check recipients/channels in budget-config.yaml (feishu, user 'wayne') so alerts are not accidentally sent to unexpected recipients.
Persistence & Privilege
always:false and the skill only reads/writes within its skill directory and /tmp usage files; it does not request system-wide changes or modify other skills. No persistent or privileged hooks detected.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install budget-analyzer-claw
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /budget-analyzer-claw 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release
元数据
Slug budget-analyzer-claw
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

budget-analyzer-claw 是什么?

预算分析虾 — OpenClaw 数字员工体系的财务守门员。实时监控所有 AI 资源支出,智能控制开销,防止产生意外的巨额费用。 当以下情况时使用此 Skill: (1) 用户询问今日/本周/本月花了多少钱 (2) 用户询问哪个数字员工最费钱、成本占比 (3) 用户要求分析成本趋势、优化建议 (4) 用户要求设置... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 101 次。

如何安装 budget-analyzer-claw?

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

budget-analyzer-claw 是免费的吗?

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

budget-analyzer-claw 支持哪些平台?

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

谁开发了 budget-analyzer-claw?

由 Ricky(@tujinsama)开发并维护,当前版本 v1.0.0。

💬 留言讨论