安全扫描
OpenClaw
安全
medium confidenceThe skill's instructions, file paths, and commands are consistent with a token- and cost‑optimization helper for OpenClaw, but several instructions are potentially destructive (deleting files, restarting gateways) and should be reviewed before execution.
评估建议
This skill appears to do what it says (optimize token usage) and makes sensible recommendations, but several instructions are potentially disruptive: they delete files and restart gateways. Before using it, (1) ensure you have recent backups of ~/.openclaw (configs, memory, workspace), (2) run the diagnostic commands manually to inspect outputs, not automatically, (3) replace destructive commands with safe dry-runs first (e.g., run find ... -print before -delete), (4) verify the referenced model...详细分析 ▾
✓ 用途与能力
The name/description (token cost optimization) matches the instructions: diagnosing cron/jobs, inspecting openclaw config and memory/workspace sizes, changing compaction settings, model routing, and pruning old files. No unrelated credentials, binaries, or external services are requested.
ℹ 指令范围
SKILL.md instructs the agent to run OpenClaw CLI commands and to read/edit files under ~/.openclaw (openclaw.json, soul.md, memory/workspace). These are within the skill's stated scope, but it also includes destructive actions (find ... -delete, removing unused skills/memory, openclaw gateway stop/start). The instructions grant broad discretion (e.g., '删除长期未用的 Skill 目录') without explicit safeguards or dry-run steps.
✓ 安装机制
Instruction-only skill with no install spec, no downloads, and no code files—lowest install risk.
✓ 凭证需求
No environment variables, credentials, or config paths outside ~/.openclaw are requested. The requested filesystem access is proportional to modifying OpenClaw configuration and cleaning OpenClaw workspaces.
✓ 持久化与权限
The skill is not always-on and does not request persistent elevated privileges or modify other skills' configs. It advises editing OpenClaw files but does not itself install components or assert permanent presence.
安全有层次,运行前请审查代码。
运行时依赖
无特殊依赖
版本
latestv1.0.02026/3/22
- Initial release of token-cost-optimizer skill. - Provides systematic guidance to reduce OpenClaw token usage and API costs across eight optimization dimensions. - Includes step-by-step diagnostic, analysis, optimization, and monitoring procedures. - Offers quick diagnostic scripts and suggested configurations for context control, model selection, agent workflow, and scheduled tasks. - Supplies reference checklists and model pricing comparisons for ongoing cost management.
● 无害
安装命令 点击复制
官方npx clawhub@latest install token-cost-optimizer
镜像加速npx clawhub@latest install token-cost-optimizer --registry https://cn.clawhub-mirror.com
技能文档
帮助用户从八个维度系统性地降低 OpenClaw 的 Token 消耗和 API 费用。
使用流程
- 诊断:先运行诊断命令,了解当前状态
- 分析:根据诊断结果,识别主要浪费点
- 优化:按优先级逐一处理,每步确认效果
- 监控:配置持续监控,防止问题复发
快速诊断脚本
一键输出所有关键信息:
echo "=== Cron 任务 ===" && openclaw cron list
echo "=== Skills 状态 ===" && openclaw skills list | grep "✓ ready"
echo "=== Memory 大小 ===" && du -sh ~/.openclaw/memory/
echo "=== Workspace 大小 ===" && du -sh ~/.openclaw/workspace/
echo "=== 当前模型 ===" && cat ~/.openclaw/openclaw.json | grep primary
echo "=== Compaction 模式 ===" && cat ~/.openclaw/openclaw.json | grep compaction -A3
八个优化维度
1. 控制上下文长度
将 compaction.mode 改为 aggressive,限制最大 token 数: 在 openclaw.json 的 agents.defaults 下设置: "compaction": { "mode": "aggressive", "maxTokens": 8000, "keepLastN": 10 }2. 要求模型简要输出
在 ~/.openclaw/soul.md 中加入: 默认简洁回复,列表不超过5条,代码只展示关键部分,避免重复内容。3. 多 Agent 并行分工
主 agent 只负责协调,子 agent 只接收精简任务描述,不传递完整上下文。 相同类型任务指定固定 agent,避免重复路由。4. 监控 API 调用频率
运行:openclaw logs | tail -100 查看近期调用 发现死循环时:openclaw gateway stop && openclaw gateway start5. 清理配置文件
清理30天前workspace文件:find ~/.openclaw/workspace -mtime +30 -type f -delete 删除长期未用的 Skill 目录和90天未更新的 memory 文件。6. 切换低价模型
kimi-k2.5(成本为0)用于简单问答 claude-haiku 用于日常任务 claude-sonnet 用于复杂分析 claude-opus 仅在必要时使用7. 配置自动模型路由
在 soul.md 中加入路由提示: 查询天气、翻译、格式转换 → kimi-k2.5 写文章、写代码、分析数据 → claude-haiku 多步骤复杂推理、交易策略分析 → claude-sonnet8. 优化定时任务
运行:openclaw cron list 查看所有任务 行情监控:交易时间内5分钟一次,收盘后停止 新闻聚合:改为30分钟或1小时一次 健康检查:改为每天一次 心跳任务:能关则关参考文件
- references/cost-checklist.md — 每周成本检查清单
- references/模型-pricing.md — 主流模型价格对比表
数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制
免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制