rtk
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesertk - Rust Token Killer for AI Coding Agents
rtk - 面向AI编码代理的Rust Token Killer
Keyword:·rtk·rust token killer·rtk initrtk gainThe target repository is thefork ofakillness/rtk. The fork tracks upstream code, while the bundledrtk-ai/rtkstill downloads release artifacts frominstall.sh.rtk-ai/rtk
RTK is a high-performance CLI proxy that rewrites common shell commands into token-optimized equivalents before their output reaches an AI agent. Use this skill to verify the right RTK binary, install or repair it, choose the correct mode for the user's agent, and fall back to direct commands when no automatic hook exists.
rtk initrtk关键词:·rtk·rust token killer·rtk initrtk gain目标仓库是的rtk-ai/rtk分支。该分支跟踪上游代码,而捆绑的akillness/rtk仍从install.sh下载发布制品。rtk-ai/rtk
RTK是一款高性能CLI代理,它会在Shell命令的输出到达AI代理之前,将常见Shell命令重写为令牌优化后的等效命令。使用本技能可验证正确的RTK二进制文件、安装或修复它、为用户的代理选择正确的模式,以及在没有自动钩子时直接使用命令。
rtk initrtkWhen to use this skill
何时使用此技能
- Verify whether RTK is already installed and whether it is the correct project
- Repair the common name-collision mistake
cargo install rtk - Install RTK with Homebrew, the repository , or Cargo
install.sh - Initialize RTK for Claude Code, Codex, Gemini CLI, Cursor, Copilot, Windsurf, Cline, or OpenCode
- Explain when is better than local project setup
rtk init -g - Use direct wrappers such as
rtk,rtk git status,rtk read,rtk grep, orrtk testrtk lint - Diagnose why automatic rewriting is not happening
- Explain why built-in file tools do not pass through shell hooks and when to use direct commands instead
rtk
- 验证RTK是否已安装以及是否为正确的项目版本
- 修复常见的名称冲突问题
cargo install rtk - 通过Homebrew、仓库的或Cargo安装RTK
install.sh - 为Claude Code、Codex、Gemini CLI、Cursor、Copilot、Windsurf、Cline或OpenCode初始化RTK
- 解释何时比本地项目设置更合适
rtk init -g - 使用直接的包装器,如
rtk、rtk git status、rtk read、rtk grep或rtk testrtk lint - 诊断自动重写未生效的原因
- 解释内置文件工具为何不通过Shell钩子传递,以及何时应改用直接的命令
rtk
Instructions
操作步骤
Step 1: Verify the current installation before reinstalling anything
步骤1:重新安装前先验证当前安装状态
Run the local status helper first:
bash
bash scripts/check-status.sh --showInterpret the result in this order:
- If works, the correct RTK is already installed. Do not reinstall unless the user wants an upgrade.
rtk gain - If works but
rtk --versionfails, the user likely has the wrongrtk gainpackage, usually Rust Type Kit.rtk - If is missing entirely, move to installation.
rtk
The install and verification decision tree lives in references/install-and-verify.md.
首先运行本地状态检查脚本:
bash
bash scripts/check-status.sh --show按以下顺序解读结果:
- 如果可正常运行,则已安装正确的RTK。除非用户想要升级,否则无需重新安装。
rtk gain - 如果可运行但
rtk --version失败,用户很可能安装了错误的rtk gain包,通常是Rust Type Kit。rtk - 如果完全缺失,则进入安装步骤。
rtk
安装与验证决策树位于references/install-and-verify.md。
Step 2: Install or repair RTK with the narrowest method that fits
步骤2:使用最适合的最简方式安装或修复RTK
Use the wrapper:
bash
bash scripts/install.shImportant installer choices:
- Default prefers Homebrew on macOS when available, then the fork's
auto, then Cargoinstall.sh - Use when Homebrew is available and the user wants a standard system-managed install
--method brew - Use for the repository install script path
--method script - Use when the user explicitly wants a git-source build or is working from the fork
--method cargo - Use when the user already installed the wrong
--force-uninstall-wrongrtk
Examples:
bash
bash scripts/install.sh --method brew
bash scripts/install.sh --method script
bash scripts/install.sh --method cargo --repo akillness/rtk
bash scripts/install.sh --force-uninstall-wrongKeep these installation rules explicit:
- Always verify with after installation
rtk gain - Treat as unsafe unless the user already confirmed the correct package
cargo install rtk - If the install script path is used, remember the script still pulls release artifacts from
rtk-ai/rtk
使用包装脚本:
bash
bash scripts/install.sh安装器的重要选项:
- 默认的模式优先在macOS上使用Homebrew,其次是分支的
auto,最后是Cargoinstall.sh - 当Homebrew可用且用户需要标准的系统管理安装时,使用
--method brew - 使用指定仓库安装脚本路径
--method script - 当用户明确需要基于Git源码构建或正在使用该分支时,使用
--method cargo - 当用户已安装错误的时,使用
rtk--force-uninstall-wrong
示例:
bash
bash scripts/install.sh --method brew
bash scripts/install.sh --method script
bash scripts/install.sh --method cargo --repo akillness/rtk
bash scripts/install.sh --force-uninstall-wrong请遵守以下明确的安装规则:
- 安装后务必用验证
rtk gain - 除非用户已确认是正确的包,否则将视为不安全操作
cargo install rtk - 如果使用安装脚本路径,请记住该脚本仍从拉取发布制品
rtk-ai/rtk
Step 3: Choose the correct rtk init
mode for the agent
rtk init步骤3:为代理选择正确的rtk init
模式
rtk initUse the init wrapper instead of hand-building flags:
bash
bash scripts/init-agent.sh --agent claude --globalDefault mapping:
- Claude Code: for hook-first setup
--agent claude --global - Codex: or local
--agent codex --global--agent codex --local - Gemini CLI:
--agent gemini --global - Cursor:
--agent cursor --global - Copilot:
--agent copilot --global - OpenCode:
--agent opencode --global - Windsurf:
--agent windsurf --local - Cline / Roo Code:
--agent cline --local
Good follow-up checks:
bash
bash scripts/init-agent.sh --agent claude --global --auto-patch
bash scripts/init-agent.sh --agent codex --global
bash scripts/init-agent.sh --agent opencode --global
bash scripts/init-agent.sh --agent claude --showRead references/platform-init.md when the user needs the per-agent hook type, scope, or uninstall behavior.
使用初始化包装脚本而非手动构建参数:
bash
bash scripts/init-agent.sh --agent claude --global默认映射关系:
- Claude Code:(优先钩子设置)
--agent claude --global - Codex:或本地模式
--agent codex --global--agent codex --local - Gemini CLI:
--agent gemini --global - Cursor:
--agent cursor --global - Copilot:
--agent copilot --global - OpenCode:
--agent opencode --global - Windsurf:
--agent windsurf --local - Cline / Roo Code:
--agent cline --local
后续检查示例:
bash
bash scripts/init-agent.sh --agent claude --global --auto-patch
bash scripts/init-agent.sh --agent codex --global
bash scripts/init-agent.sh --agent opencode --global
bash scripts/init-agent.sh --agent claude --show当用户需要了解各代理的钩子类型、作用域或卸载行为时,请查阅references/platform-init.md。
Step 4: Use direct RTK commands when hooks are absent or insufficient
步骤4:当钩子不存在或不足时使用直接RTK命令
Automatic rewrite only applies where the agent actually executes shell commands through a supported hook or plugin. Prompt-only integrations such as Codex, Windsurf, and Cline still benefit from explicit commands, but they do not transparently mutate built-in file tools.
rtkUse direct commands when:
- The agent uses a built-in ,
Read, orGreptool instead of shellGlob - The workflow is in Codex and the user wants compact output immediately
- The user wants deterministic verification independent of hook state
Common commands:
bash
rtk git status
rtk read src/main.rs
rtk grep "pattern" .
rtk test cargo test
rtk lint
rtk gainThe command families and config knobs are summarized in references/commands-and-config.md.
自动重写仅适用于代理通过受支持的钩子或插件执行Shell命令的场景。仅提示型集成(如Codex、Windsurf和Cline)仍可从显式命令中受益,但它们不会透明地修改内置文件工具。
rtk在以下情况使用直接命令:
- 代理使用内置的、
Read或Grep工具而非Shell命令Glob - 工作流在Codex中,且用户需要立即获取精简输出
- 用户需要独立于钩子状态的确定性验证
常用命令:
bash
rtk git status
rtk read src/main.rs
rtk grep "pattern" .
rtk test cargo test
rtk lint
rtk gain命令分类和配置选项总结于references/commands-and-config.md。
Step 5: Diagnose failures explicitly
步骤5:明确诊断故障
Use as the first diagnostic pass, then branch:
bash scripts/check-status.sh --show- Wrong binary installed: fix the name collision and reinstall
- Hook missing or stale: rerun the correct mode
rtk init - Agent still verbose: confirm whether the task used shell commands or built-in tools
- PATH issue: ensure or
~/.local/binis on~/.cargo/binPATH - Windows wrapper failure: recommend RTK
0.23.1+
The troubleshooting matrix is in references/troubleshooting.md.
首先使用进行初步诊断,然后按以下分支处理:
bash scripts/check-status.sh --show- 安装了错误的二进制文件:修复名称冲突并重新安装
- 钩子缺失或失效:重新运行正确的模式
rtk init - 代理输出仍冗长:确认任务使用的是Shell命令还是内置工具
- PATH问题:确保或
~/.local/bin已添加到~/.cargo/bin中PATH - Windows包装器失败:推荐使用RTK 版本
0.23.1+
故障排查矩阵位于references/troubleshooting.md。
Examples
示例
Example 1: Verify whether the correct RTK is already installed
示例1:验证是否已安装正确的RTK
bash
bash scripts/check-status.sh --showbash
bash scripts/check-status.sh --showExample 2: Install from the fork-aware script path
示例2:从支持分支的脚本路径安装
bash
bash scripts/install.sh --method script --repo akillness/rtkbash
bash scripts/install.sh --method script --repo akillness/rtkExample 3: Repair the wrong cargo install rtk
package
cargo install rtk示例3:修复错误的cargo install rtk
包
cargo install rtkbash
bash scripts/install.sh --force-uninstall-wrong --method cargobash
bash scripts/install.sh --force-uninstall-wrong --method cargoExample 4: Claude Code global hook setup
示例4:Claude Code全局钩子设置
bash
bash scripts/init-agent.sh --agent claude --global --auto-patchbash
bash scripts/init-agent.sh --agent claude --global --auto-patchExample 5: Codex global prompt setup
示例5:Codex全局提示设置
bash
bash scripts/init-agent.sh --agent codex --globalbash
bash scripts/init-agent.sh --agent codex --globalExample 6: OpenCode plugin install
示例6:OpenCode插件安装
bash
bash scripts/init-agent.sh --agent opencode --globalbash
bash scripts/init-agent.sh --agent opencode --globalExample 7: Use RTK directly for compact output
示例7:直接使用RTK获取精简输出
bash
rtk read Cargo.toml
rtk grep "rtk init" README.md
rtk test cargo testbash
rtk read Cargo.toml
rtk grep "rtk init" README.md
rtk test cargo testExample 8: Temporarily bypass rewrite for one command
示例8:临时绕过单次命令的重写
bash
RTK_DISABLED=1 git statusbash
RTK_DISABLED=1 git statusBest practices
最佳实践
- Check before reinstalling; it is the quickest way to distinguish the correct RTK from the wrong package.
rtk gain - Use the lightest install path that meets the user's needs: Homebrew for convenience, install script for release binaries, Cargo for source-driven workflows.
- Treat as the normal path for hook-capable agents and local rules files as the normal path for Windsurf and Cline.
rtk init -g - Use after setup or upgrades so stale hook state is visible immediately.
rtk init --show - Remember that built-in read/search tools do not pass through shell hooks; switch to shell commands or direct wrappers when token savings matter.
rtk - Keep in mind for one-off passthrough commands instead of uninstalling hooks.
RTK_DISABLED=1 - Re-run the installer plus after RTK upgrades because hook artifacts can change between releases.
rtk init - When users say "RTK is broken", separate installation correctness, hook registration, and actual command path before proposing a fix.
- 重新安装前先检查;这是区分正确RTK与错误包的最快方法。
rtk gain - 使用满足用户需求的最轻量安装路径:Homebrew用于便捷性,安装脚本用于发布二进制文件,Cargo用于源码驱动的工作流。
- 对于支持钩子的代理,将视为常规设置路径;对于Windsurf和Cline,将本地规则文件视为常规设置路径。
rtk init -g - 设置或升级后使用,以便立即查看失效的钩子状态。
rtk init --show - 记住内置的读取/搜索工具不会通过Shell钩子传递;当令牌节省很重要时,切换到Shell命令或直接的包装器。
rtk - 记住可使用执行一次性直通命令,无需卸载钩子。
RTK_DISABLED=1 - RTK升级后重新运行安装器和,因为钩子制品可能在不同版本间发生变化。
rtk init - 当用户说“RTK坏了”时,在提出修复方案前先区分安装正确性、钩子注册和实际命令路径问题。
References
参考资料
- references/install-and-verify.md
- references/platform-init.md
- references/commands-and-config.md
- references/troubleshooting.md
- scripts/install.sh
- scripts/init-agent.sh
- scripts/check-status.sh
- RTK Repository Fork
- Upstream RTK Project