LLM 上下文压缩神器,省 90% Token
简介
RTK 通过智能过滤 shell 输出,为 LLM 节省 60-90% token 消耗,兼容 Claude/GPT 等所有模型,特别适合高频 git、测试、构建场景。
原始描述
Integrate RTK (Rust Token Killer) to reduce LLM token consumption by 60-90% on shell commands. Use when setting up RTK for the first time, checking token sav...
通过你的 Agent 添加
安装目录:rtk-integration/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: rtk-integration
description: "Integrate RTK (Rust Token Killer) to reduce LLM token consumption by 60-90% on shell commands. Use when setting up RTK for the first time, checking token savings with 'rtk gain', or when the agent should use rtk-prefixed commands instead of raw shell commands (git, grep, find, ls, cat, test runners, linters, docker, npm/yarn/pnpm, etc.). RTK works transparently with any LLM backend (Claude, MiniMax, GPT, Gemini, OpenClaw, etc.) — it filters shell output before it reaches the context window. Trigger phrases: token savings, setup rtk, rtk gain, optimize tokens, context window, reduce costs."
RTK Integration
RTK filters and compresses shell command outputs before they reach the LLM context window. Works with any agent/model (Claude, MiniMax, GPT, Gemini, OpenClaw, etc.) — model-agnostic.
Setup
1. Install RTK (if not present)
# Check if installed
which rtk && rtk --version
# Linux/macOS (recommended)
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
# macOS Homebrew
brew install rtk
# Verify
rtk --version && rtk gain
2. Initialize hooks (optional, for Claude Code / OpenCode auto-rewriting)
rtk init --global # Claude Code hook
rtk init --global --opencode # OpenCode hook
⚠️ For OpenClaw agents: hooks don't auto-apply. Use rtk <cmd> explicitly (see below).
3. Check token savings
rtk gain
rtk init --global # Claude Code hook
rtk init --global --opencode # OpenCode hook
⚠️ For OpenClaw agents: hooks don't auto-apply. Use rtk <cmd> explicitly (see below).
rtk gain
For config customization, see references/config.md.
Core Rule: Always Use RTK Prefixes
When executing shell commands, always prefer the RTK version over the raw command. RTK adds <10ms overhead and reduces output by 60–90%.
See the full command reference: references/commands.md
Quick reference (most common)
# Files
rtk ls .
rtk read <file>
rtk grep "<pattern>" .
rtk find "*.ts" .
rtk diff file1 file2
# Git (most impactful — use on EVERY git operation)
rtk git status
rtk git diff
rtk git log -n 10
rtk git add . # outputs just "ok"
rtk git commit -m "msg" # outputs "ok <hash>"
rtk git push # outputs "ok main"
rtk git pull
# Tests — show failures only (-90%)
rtk test npm test
rtk test npx jest
rtk vitest run
rtk playwright test
rtk pytest
rtk go test
rtk cargo test
# Build & lint
rtk tsc
rtk next build
rtk lint
rtk lint biome
rtk cargo build
rtk cargo clippy
rtk ruff check .
# Docker
rtk docker ps
rtk docker logs <container>
# Package managers
rtk pnpm install
rtk npm install
rtk yarn install
When NOT to use RTK
- Interactive commands (ssh, vim, htop) — use directly
- Already-compressed output (jq-piped JSON, single-line results)
- When you need the full raw output for debugging
rtk gain — Token Savings Report
# Files
rtk ls .
rtk read <file>
rtk grep "<pattern>" .
rtk find "*.ts" .
rtk diff file1 file2
# Git (most impactful — use on EVERY git operation)
rtk git status
rtk git diff
rtk git log -n 10
rtk git add . # outputs just "ok"
rtk git commit -m "msg" # outputs "ok <hash>"
rtk git push # outputs "ok main"
rtk git pull
# Tests — show failures only (-90%)
rtk test npm test
rtk test npx jest
rtk vitest run
rtk playwright test
rtk pytest
rtk go test
rtk cargo test
# Build & lint
rtk tsc
rtk next build
rtk lint
rtk lint biome
rtk cargo build
rtk cargo clippy
rtk ruff check .
# Docker
rtk docker ps
rtk docker logs <container>
# Package managers
rtk pnpm install
rtk npm install
rtk yarn install
- Interactive commands (ssh, vim, htop) — use directly
- Already-compressed output (jq-piped JSON, single-line results)
- When you need the full raw output for debugging
rtk gain — Token Savings Report
Run rtk gain whenever user asks about token savings. Output example:
📊 RTK Token Savings
════════════════════════════════
Total commands: 1,247
Input tokens: 4.8M
Output tokens: 0.6M
Tokens saved: 4.2M (87.5%)
By Command:
rtk git status 215 1.4M 80.8%
rtk grep 227 786K 49.5%
rtk find 324 6.8M 78.3%
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。