闲社服务运行正常AI智能体自动化平台
r

集成RTK减少令牌消耗

技能标识:rtk-integration

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. Trig

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.1.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

集成RTK减少令牌消耗

RTK 集成

RTK 在 shell 命令输出到达 LLM 上下文窗口之前对其进行过滤和压缩。可与任何智能体/模型(Claude、MiniMax、GPT、Gemini、OpenClaw 等)配合使用——与模型无关。

设置

1. 安装 RTK(自动——在技能安装时运行)

安装此技能时,立即运行设置脚本以安装 RTK(如果尚未安装):

bash
bash skills/rtk-integration/scripts/rtk-setup.sh

该脚本自动处理安装(Linux/macOS),将 RTK 添加到 PATH,并验证安装。

如需手动安装:

bash

Linux/macOS


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

验证

rtk --version && rtk gain

2. 初始化钩子(可选,用于 Claude Code / OpenCode 自动重写)

bash
rtk init --global # Claude Code 钩子
rtk init --global --opencode # OpenCode 钩子

⚠️ 对于 OpenClaw 智能体:钩子不会自动应用。请显式使用 rtk (见下文)。

3. 查看令牌节省量

bash
rtk gain

有关配置自定义,请参阅 references/config.md。



核心规则:始终使用 RTK 前缀

执行 shell 命令时,始终优先使用 RTK 版本而非原始命令。RTK 增加不到 10ms 的开销,并将输出减少 60–90%。

查看完整命令参考:references/commands.md

快速参考(最常用)

bash

文件


rtk ls .
rtk read
rtk grep .
rtk find *.ts .
rtk diff file1 file2

Git(效果最显著——每次 Git 操作都使用)

rtk git status rtk git diff rtk git log -n 10 rtk git add . # 仅输出 ok rtk git commit -m msg # 输出 ok rtk git push # 输出 ok main rtk git pull

测试——仅显示失败信息(-90%)

rtk test npm test rtk test npx jest rtk vitest run rtk playwright test rtk pytest rtk go test rtk cargo test

构建与代码检查

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

包管理器

rtk pnpm install rtk npm install rtk yarn install

何时不使用 RTK

  • - 交互式命令(ssh、vim、htop)——直接使用
  • 已压缩的输出(通过 jq 管道处理的 JSON、单行结果)
  • 需要完整原始输出进行调试时

rtk gain——令牌节省报告

每当用户询问令牌节省情况时,运行 rtk gain。输出示例:

📊 RTK 令牌节省量
════════════════════════════════
总命令数: 1,247
输入令牌: 4.8M
输出令牌: 0.6M
节省令牌: 4.2M(87.5%)

按命令统计:
rtk git status 215 1.4M 80.8%
rtk grep 227 786K 49.5%
rtk find 324 6.8M 78.3%

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 rtk-integration-1776111001 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 rtk-integration-1776111001 技能

通过命令行安装

skillhub install rtk-integration-1776111001

下载

⬇ 下载 rtk-integration v1.1.0(免费)

文件大小: 5.88 KB | 发布时间: 2026-4-17 15:58

v1.1.0 最新 2026-4-17 15:58
v1.1.0: Auto-install RTK on skill setup. Script now handles PATH, detects shell profile (.zshrc/.bashrc/.profile), works on Linux and macOS.
返回顶部