Save 60-90% of LLM tokens on shell commands, file reads, and test outputs.
This skill wraps rtk (Rust Token Killer) — a CLI proxy that filters and compresses command outputs before they reach your LLM context.
Install
CODEBLOCK0
Then copy this SKILL.md to your agent's skills directory.
Commands Reference
Smart File Operations
CODEBLOCK1
Search & Diff
CODEBLOCK2
Git Operations
CODEBLOCK3
GitHub CLI
CODEBLOCK4
Test Runners
CODEBLOCK5
Build & Lint
CODEBLOCK6
Package Managers
CODEBLOCK7
Containers
CODEBLOCK8
Data & Analytics
CODEBLOCK9
Token Savings Analytics
CODEBLOCK10
Rules for the Agent
Use rtk <command> instead of bare commands whenever possible:
Always use rtk for:
- -
rtk git status / rtk git log / INLINECODE4 - INLINECODE5 / INLINECODE6
- INLINECODE7 /
rtk pytest / INLINECODE9 - INLINECODE10 / INLINECODE11
Don't use rtk for:
- - Commands whose output is piped to other tools (e.g.,
git log | grep ...) - Scripts that parse raw output
- Commands where you need the exact full output
If rtk fails:
Fall back to the bare command. Never block a task because of compression.
Check savings:
CODEBLOCK11
Token Savings Reference
| Operation | Without rtk | With rtk | Savings |
|---|
| INLINECODE13 | ~300 | ~60 | -80% |
| INLINECODE14 |
~2,000 | ~400 | -80% |
|
cat file.ts | ~2,000 | ~600 | -70% |
|
npm test | ~5,000 | ~500 | -90% |
|
pytest | ~2,000 | ~200 | -90% |
|
Typical session |
~150k |
~45k |
-70% |
Links
- - rtk: https://github.com/rtk-ai/rtk
- OpenClaw feature request: https://github.com/openclaw/openclaw/issues/35053
技能名称: rtk-compress
详细描述:
在 shell 命令、文件读取和测试输出上节省 60-90% 的 LLM 令牌。
此技能封装了 rtk (Rust Token Killer) — 一个 CLI 代理,可在命令输出到达 LLM 上下文之前对其进行过滤和压缩。
安装
bash
1. 安装 rtk
brew install rtk # macOS
或: curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
2. 验证
rtk gain # 应显示令牌节省统计信息
然后将此 SKILL.md 文件复制到你的代理技能目录中。
命令参考
智能文件操作
bash
rtk ls . # 令牌优化的目录树
rtk read file.rs # 智能文件读取(压缩输出)
rtk read file.rs -l aggressive # 仅签名(去除主体)
rtk smart file.rs # 2 行启发式代码摘要
搜索与差异比较
bash
rtk find *.rs . # 紧凑的查找结果
rtk grep pattern . # 分组搜索结果
rtk diff file1 file2 # 精简差异
Git 操作
bash
rtk git status # 紧凑状态
rtk git log -n 10 # 单行提交
rtk git diff # 精简差异
rtk git add # → ok
rtk git commit -m msg # → ok abc1234
rtk git push # → ok main
rtk git pull # → ok 3 files +10 -2
GitHub CLI
bash
rtk gh pr list # 紧凑的 PR 列表
rtk gh pr view 42 # PR 详情 + 检查
rtk gh issue list # 紧凑的问题列表
rtk gh run list # 工作流运行状态
测试运行器
bash
rtk test cargo test # 仅显示失败项(-90%)
rtk err npm run build # 仅显示错误/警告
rtk vitest run # Vitest 紧凑模式(仅失败项)
rtk playwright test # E2E 结果(仅失败项)
rtk pytest # Python 测试(-90%)
rtk go test # Go 测试(NDJSON,-90%)
rtk cargo test # Cargo 测试(-90%)
构建与代码检查
bash
rtk lint # ESLint 按规则/文件分组
rtk lint biome # 支持其他代码检查工具
rtk tsc # TypeScript 错误按文件分组
rtk next build # Next.js 构建紧凑模式
rtk prettier --check . # 需要格式化的文件
rtk cargo build # Cargo 构建(-80%)
rtk cargo clippy # Cargo clippy(-80%)
rtk ruff check # Python 代码检查(JSON,-80%)
rtk golangci-lint run # Go 代码检查(JSON,-85%)
包管理器
bash
rtk pnpm list # 紧凑的依赖树
rtk pip list # Python 包(自动检测 uv)
rtk pip outdated # 过时的包
rtk prisma generate # 模式生成(无 ASCII 艺术)
容器
bash
rtk docker ps # 紧凑的容器列表
rtk docker images # 紧凑的镜像列表
rtk docker logs
# 去重日志
rtk docker compose ps # Compose 服务
rtk kubectl pods # 紧凑的 Pod 列表
rtk kubectl logs # 去重日志
rtk kubectl services # 紧凑的服务列表
数据与分析
bash
rtk json config.json # 无值的结构
rtk deps # 依赖项摘要
rtk env -f AWS # 过滤后的环境变量
rtk log app.log # 去重日志
rtk curl # 自动检测 JSON + 模式
rtk wget # 下载,去除进度条
rtk summary # 启发式摘要
rtk proxy # 原始透传 + 跟踪
令牌节省分析
bash
rtk gain # 摘要统计
rtk gain --graph # ASCII 图表(最近 30 天)
rtk gain --history # 最近命令历史
rtk gain --daily # 逐日分解
rtk gain --all --format json # 用于仪表板的 JSON 导出
rtk discover # 查找错过的节省机会
rtk discover --all --since 7 # 所有项目,最近 7 天
代理规则
尽可能使用 rtk 代替裸命令:
始终使用 rtk 的场景:
- - rtk git status / rtk git log / rtk git diff
- rtk ls -la / rtk cat
- rtk npm test / rtk pytest / rtk cargo test
- rtk npm run build / rtk ruff check
不使用 rtk 的场景:
- - 输出被管道传递给其他工具的命令(例如 git log | grep ...)
- 解析原始输出的脚本
- 需要精确完整输出的命令
如果 rtk 失败:
回退到裸命令。切勿因压缩问题阻塞任务。
检查节省情况:
bash
rtk gain # 当前会话
rtk gain --global # 所有时间统计
令牌节省参考
| 操作 | 无 rtk | 有 rtk | 节省 |
|---|
| git status | ~300 | ~60 | -80% |
| git log -20 |
~2,000 | ~400 | -80% |
| cat file.ts | ~2,000 | ~600 | -70% |
| npm test | ~5,000 | ~500 | -90% |
| pytest | ~2,000 | ~200 | -90% |
| 典型会话 | ~150k | ~45k | -70% |
链接
- - rtk: https://github.com/rtk-ai/rtk
- OpenClaw 功能请求: https://github.com/openclaw/openclaw/issues/35053