Token Kill - OpenClaw Token Optimizer
Need help optimizing your OpenClaw token usage costs? This Skill will guide you through three powerful optimization techniques to dramatically reduce token consumption.
Based on real-world case studies, applying these optimization techniques can reduce token consumption from $200+/day to $10/day, achieving a 95%+ cost reduction.
Three Core Token Optimization Techniques
1️⃣ Slash Commands Optimization
- -
/new - Start a fresh conversation and clear old context (saves 50,000+ tokens) - INLINECODE1 - Compress memory by keeping important info and forgetting details (saves 30,000+ tokens)
- INLINECODE2 - Immediately stop current task to prevent further token consumption
- INLINECODE3 - Restart the system to clear lag and resolve issues
2️⃣ Script-First Principle
Core Philosophy: AI is your brain, not your hands
Automate with scripts instead of using the model for mechanical tasks:
- - 📧 Email Checking - Scripts monitor emails; AI only notified of new messages ($100+/month → <$1/month)
- 🌤️ Weather Queries - Direct API calls, zero token consumption
- 📊 Data Fetching - Scripts retrieve data; AI only handles formatting
- ⏰ Scheduled Tasks - Scripts execute; prevent AI from polling
- 🔄 Data Processing - Script handles transformations
3️⃣ Model Tiering Strategy
Use premium models for complex tasks, budget models for simple ones
| Complexity | Recommended Model | Cost | Use Cases | Savings |
|---|
| 🔴 High | GPT-4 / Claude | $0.03/1k tokens | Code generation, creative writing, complex reasoning | Baseline |
| 🟡 Medium |
GPT-3.5-Turbo / Ernie | $0.0005/1k tokens | General tasks, text editing | 98% |
| 🟢 Low | Qwen, Tongyi (Budget Models) | $0.00001/1k tokens | Data processing, report generation, formatting |
99.97% |
Real-World Cost Reduction Cases
Case 1: Email Monitoring System
Problem: Model checks emails every 5 minutes
| Approach | Monthly Cost |
|---|
| ❌ Model Polling | $100+/month |
| ✅ Script + AI Notification |
<$1/month |
|
Savings |
99% |
Case 2: Daily Report Generation
Scenario: Generate reports every 30 minutes (2000 tokens/call)
| Model | Daily Cost | Monthly Cost | Savings |
|---|
| GPT-4 | $2.88 | $86 | Baseline |
| GPT-3.5 |
$0.048 | $1.44 | 98% |
| Qwen | $0.001 | $0.03 |
99.97% |
Examples
Example 1: Compressing Large Memory
Scenario: After many conversations, memory.md has grown to hundreds of thousands of characters
Solution:
- 1. Execute
/compress command - System removes trivial details while preserving core information
- Memory size reduced by 30-50%
Result: Reduced context loading on each turn, saves 30,000+ tokens
Example 2: Replacing AI with Scripts
Scenario: Need to check for new orders every hour
Wrong Approach:
CODEBLOCK0
Correct Approach:
CODEBLOCK1
Savings: Script uses only CPU, saves 90%+ tokens
Example 3: Model Tiering Workflow
Scenario: Handle various complexity levels
Strategy:
- - 💻 Code Writing → GPT-4 (worth the investment)
- 📝 Content Editing → GPT-3.5 (good balance)
- 📊 Report Generation → Budget Model (fully sufficient)
Result: 90% cost reduction, zero functionality loss
Guidelines
✅ Best Practices for Token Savings
1. Use Slash Commands Regularly
- - Execute
/compress once daily - Prevent memory bloat - Use
/new for long conversations - Start fresh after 1+ hours - Use
/stop on wrong tasks - Stop immediately to prevent waste
2. Strictly Follow Script-First Principle
- - ✅ Scripts handle: Scheduled checks, data fetching, API calls, data processing
- ❌ Never let AI handle: Polling, mechanical work, repetitive checks, resource-intensive operations
- 💡 Core rule: AI = decision-making and judgment; Scripts = execution and heavy lifting
3. Enforce Model Tiering
| Task Type | Model Choice | Reason |
|---|
| Code generation, deep analysis | GPT-4 | Complex tasks worth the cost |
| General tasks, text editing |
GPT-3.5 | Best value proposition |
| Data processing, reports | Budget Models | Fully capable, lowest cost |
4. Regular Token Usage Audit
- - Review billing distribution
- Identify high-cost tasks for optimization
- Adjust model configuration and scripts
❌ Common Token Wastage Patterns
| Bad Practice | Consequence | Solution |
|---|
| Unlimited conversation history | Growing memory = more tokens | Regular /compress or INLINECODE9 |
| AI polling for updates |
Token burn on each check | Use scripts instead |
| Using GPT-4 for simple tasks | Overkill, high cost | Use appropriate model tier |
| Never compressing memory | Linear token cost growth | Establish compression habit |
| Continuing failed tasks | Wasted tokens | Use
/stop immediately |
Token Cost Formula
CODEBLOCK2
Combining all three techniques achieves 95%+ cost reduction.
Key Principle
💡 Remember: High costs don't come from AI itself, but from making it do tasks it shouldn't do and remember information it shouldn't store.
Assign the right tasks to the right tools, and AI becomes truly cost-effective.
Token Kill - OpenClaw Token优化器
需要帮助优化您的OpenClaw Token使用成本吗?本技能将引导您掌握三种强大的优化技术,大幅降低Token消耗。
基于真实案例研究,应用这些优化技术可将Token消耗从每天200美元以上降至每天10美元,实现95%以上的成本降低。
三大核心Token优化技术
1️⃣ 斜杠命令优化
- - /new - 开启全新对话,清除旧上下文(节省50,000+ Token)
- /compress - 压缩记忆,保留重要信息,遗忘细节(节省30,000+ Token)
- /stop - 立即停止当前任务,防止进一步Token消耗
- /stop - 立即停止当前任务,防止进一步Token消耗
- /restart - 重启系统,清除延迟并解决问题
2️⃣ 脚本优先原则
核心理念:AI是你的大脑,不是你的双手
用脚本自动化替代模型执行机械任务:
- - 📧 邮件检查 - 脚本监控邮件;仅在有新消息时通知AI(每月100美元以上 → 每月不到1美元)
- 🌤️ 天气查询 - 直接调用API,零Token消耗
- 📊 数据获取 - 脚本检索数据;AI仅负责格式化
- ⏰ 定时任务 - 脚本执行;防止AI轮询
- 🔄 数据处理 - 脚本处理转换
3️⃣ 模型分层策略
复杂任务使用高级模型,简单任务使用经济模型
| 复杂度 | 推荐模型 | 成本 | 使用场景 | 节省比例 |
|---|
| 🔴 高 | GPT-4 / Claude | $0.03/千Token | 代码生成、创意写作、复杂推理 | 基准线 |
| 🟡 中 |
GPT-3.5-Turbo / Ernie | $0.0005/千Token | 通用任务、文本编辑 | 98% |
| 🟢 低 | Qwen、通义(经济模型) | $0.00001/千Token | 数据处理、报告生成、格式化 |
99.97% |
真实成本降低案例
案例1:邮件监控系统
问题:模型每5分钟检查一次邮件
| 方案 | 月成本 |
|---|
| ❌ 模型轮询 | 每月100美元以上 |
| ✅ 脚本+AI通知 |
每月不到1美元 |
|
节省 |
99% |
案例2:日报生成
场景:每30分钟生成一次报告(每次2000 Token)
| 模型 | 日成本 | 月成本 | 节省比例 |
|---|
| GPT-4 | $2.88 | $86 | 基准线 |
| GPT-3.5 |
$0.048 | $1.44 | 98% |
| Qwen | $0.001 | $0.03 |
99.97% |
示例
示例1:压缩大容量记忆
场景:多次对话后,memory.md已增长到数十万字
解决方案:
- 1. 执行 /compress 命令
- 系统移除琐碎细节,保留核心信息
- 记忆大小减少30-50%
结果:减少每次轮次的上下文加载,节省30,000+ Token
示例2:用脚本替代AI
场景:需要每小时检查新订单
错误方法:
让模型每小时检查订单API
→ 模型每次都需要理解和判断
→ 每天24次检查 = 巨大成本
正确方法:
脚本每小时检查订单API
仅在有新订单时通知模型
模型只负责决策处理
节省:脚本仅使用CPU,节省90%以上Token
示例3:模型分层工作流
场景:处理不同复杂度的任务
策略:
- - 💻 代码编写 → GPT-4(值得投资)
- 📝 内容编辑 → GPT-3.5(良好平衡)
- 📊 报告生成 → 经济模型(完全够用)
结果:成本降低90%,功能零损失
指南
✅ Token节省最佳实践
1. 定期使用斜杠命令
- - 每天执行一次 /compress - 防止记忆膨胀
- 长对话使用 /new - 1小时后开启新对话
- 错误任务使用 /stop - 立即停止,防止浪费
2. 严格遵守脚本优先原则
- - ✅ 脚本处理:定时检查、数据获取、API调用、数据处理
- ❌ 绝不让AI处理:轮询、机械工作、重复检查、资源密集型操作
- 💡 核心规则:AI = 决策和判断;脚本 = 执行和繁重工作
3. 强制模型分层
| 任务类型 | 模型选择 | 原因 |
|---|
| 代码生成、深度分析 | GPT-4 | 复杂任务值得投入 |
| 通用任务、文本编辑 |
GPT-3.5 | 最佳性价比 |
| 数据处理、报告 | 经济模型 | 完全够用,成本最低 |
4. 定期Token使用审计
- - 审查账单分布
- 识别高成本任务进行优化
- 调整模型配置和脚本
❌ 常见Token浪费模式
| 不良实践 | 后果 | 解决方案 |
|---|
| 无限对话历史 | 记忆增长 = 更多Token | 定期 /compress 或 /new |
| AI轮询更新 |
每次检查都消耗Token | 改用脚本 |
| 简单任务使用GPT-4 | 过度杀伤,成本高 | 使用合适的模型层级 |
| 从不压缩记忆 | Token成本线性增长 | 养成压缩习惯 |
| 继续失败任务 | 浪费Token | 立即使用 /stop |
Token成本公式
总成本 = 上下文消耗 + 任务消耗
优化公式:
新成本 = (原始上下文 × 30%) + (任务成本 × 20%)
= 原始成本 × (0.3 + 0.2)
= 原始成本 × 0.5 或更低
结合所有三种技术可实现95%以上的成本降低。
核心原则
💡 记住:高成本并非来自AI本身,而是让它做不该做的事、记不该记的信息。
将正确的任务分配给正确的工具,AI才能真正实现成本效益。