rtk

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

rtk - Rust Token Killer for AI Coding Agents

rtk - 面向AI编码代理的Rust Token Killer

Keyword:
rtk
·
rust token killer
·
rtk init
·
rtk gain
The target repository is the
akillness/rtk
fork of
rtk-ai/rtk
. The fork tracks upstream code, while the bundled
install.sh
still downloads release artifacts from
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
rtk init
mode for the user's agent, and fall back to direct
rtk
commands when no automatic hook exists.
关键词:
rtk
·
rust token killer
·
rtk init
·
rtk gain
目标仓库是
rtk-ai/rtk
akillness/rtk
分支。该分支跟踪上游代码,而捆绑的
install.sh
仍从
rtk-ai/rtk
下载发布制品。
RTK是一款高性能CLI代理,它会在Shell命令的输出到达AI代理之前,将常见Shell命令重写为令牌优化后的等效命令。使用本技能可验证正确的RTK二进制文件、安装或修复它、为用户的代理选择正确的
rtk init
模式,以及在没有自动钩子时直接使用
rtk
命令。

When to use this skill

何时使用此技能

  • Verify whether RTK is already installed and whether it is the correct project
  • Repair the common
    cargo install rtk
    name-collision mistake
  • Install RTK with Homebrew, the repository
    install.sh
    , or Cargo
  • Initialize RTK for Claude Code, Codex, Gemini CLI, Cursor, Copilot, Windsurf, Cline, or OpenCode
  • Explain when
    rtk init -g
    is better than local project setup
  • Use direct
    rtk
    wrappers such as
    rtk git status
    ,
    rtk read
    ,
    rtk grep
    ,
    rtk test
    , or
    rtk 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
    rtk
    commands instead
  • 验证RTK是否已安装以及是否为正确的项目版本
  • 修复常见的
    cargo install rtk
    名称冲突问题
  • 通过Homebrew、仓库的
    install.sh
    或Cargo安装RTK
  • 为Claude Code、Codex、Gemini CLI、Cursor、Copilot、Windsurf、Cline或OpenCode初始化RTK
  • 解释何时
    rtk init -g
    比本地项目设置更合适
  • 使用直接的
    rtk
    包装器,如
    rtk git status
    rtk read
    rtk grep
    rtk test
    rtk 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 --show
Interpret the result in this order:
  1. If
    rtk gain
    works, the correct RTK is already installed. Do not reinstall unless the user wants an upgrade.
  2. If
    rtk --version
    works but
    rtk gain
    fails, the user likely has the wrong
    rtk
    package, usually Rust Type Kit.
  3. If
    rtk
    is missing entirely, move to installation.
The install and verification decision tree lives in references/install-and-verify.md.
首先运行本地状态检查脚本:
bash
bash scripts/check-status.sh --show
按以下顺序解读结果:
  1. 如果
    rtk gain
    可正常运行,则已安装正确的RTK。除非用户想要升级,否则无需重新安装。
  2. 如果
    rtk --version
    可运行但
    rtk gain
    失败,用户很可能安装了错误的
    rtk
    包,通常是Rust Type Kit。
  3. 如果
    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.sh
Important installer choices:
  • Default
    auto
    prefers Homebrew on macOS when available, then the fork's
    install.sh
    , then Cargo
  • Use
    --method brew
    when Homebrew is available and the user wants a standard system-managed install
  • Use
    --method script
    for the repository install script path
  • Use
    --method cargo
    when the user explicitly wants a git-source build or is working from the fork
  • Use
    --force-uninstall-wrong
    when the user already installed the wrong
    rtk
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-wrong
Keep these installation rules explicit:
  • Always verify with
    rtk gain
    after installation
  • Treat
    cargo install rtk
    as unsafe unless the user already confirmed the correct package
  • If the install script path is used, remember the script still pulls release artifacts from
    rtk-ai/rtk
使用包装脚本:
bash
bash scripts/install.sh
安装器的重要选项:
  • 默认的
    auto
    模式优先在macOS上使用Homebrew,其次是分支的
    install.sh
    ,最后是Cargo
  • 当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

步骤3:为代理选择正确的
rtk init
模式

Use the init wrapper instead of hand-building flags:
bash
bash scripts/init-agent.sh --agent claude --global
Default mapping:
  • Claude Code:
    --agent claude --global
    for hook-first setup
  • Codex:
    --agent codex --global
    or local
    --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 --show
Read 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
rtk
commands, but they do not transparently mutate built-in file tools.
Use direct commands when:
  • The agent uses a built-in
    Read
    ,
    Grep
    , or
    Glob
    tool instead of shell
  • 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 gain
The command families and config knobs are summarized in references/commands-and-config.md.
自动重写仅适用于代理通过受支持的钩子或插件执行Shell命令的场景。仅提示型集成(如Codex、Windsurf和Cline)仍可从显式
rtk
命令中受益,但它们不会透明地修改内置文件工具。
在以下情况使用直接命令:
  • 代理使用内置的
    Read
    Grep
    Glob
    工具而非Shell命令
  • 工作流在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
bash scripts/check-status.sh --show
as the first diagnostic pass, then branch:
  • Wrong binary installed: fix the name collision and reinstall
  • Hook missing or stale: rerun the correct
    rtk init
    mode
  • Agent still verbose: confirm whether the task used shell commands or built-in tools
  • PATH issue: ensure
    ~/.local/bin
    or
    ~/.cargo/bin
    is on
    PATH
  • 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 --show
bash
bash scripts/check-status.sh --show

Example 2: Install from the fork-aware script path

示例2:从支持分支的脚本路径安装

bash
bash scripts/install.sh --method script --repo akillness/rtk
bash
bash scripts/install.sh --method script --repo akillness/rtk

Example 3: Repair the wrong
cargo install rtk
package

示例3:修复错误的
cargo install rtk

bash
bash scripts/install.sh --force-uninstall-wrong --method cargo
bash
bash scripts/install.sh --force-uninstall-wrong --method cargo

Example 4: Claude Code global hook setup

示例4:Claude Code全局钩子设置

bash
bash scripts/init-agent.sh --agent claude --global --auto-patch
bash
bash scripts/init-agent.sh --agent claude --global --auto-patch

Example 5: Codex global prompt setup

示例5:Codex全局提示设置

bash
bash scripts/init-agent.sh --agent codex --global
bash
bash scripts/init-agent.sh --agent codex --global

Example 6: OpenCode plugin install

示例6:OpenCode插件安装

bash
bash scripts/init-agent.sh --agent opencode --global
bash
bash scripts/init-agent.sh --agent opencode --global

Example 7: Use RTK directly for compact output

示例7:直接使用RTK获取精简输出

bash
rtk read Cargo.toml
rtk grep "rtk init" README.md
rtk test cargo test
bash
rtk read Cargo.toml
rtk grep "rtk init" README.md
rtk test cargo test

Example 8: Temporarily bypass rewrite for one command

示例8:临时绕过单次命令的重写

bash
RTK_DISABLED=1 git status
bash
RTK_DISABLED=1 git status

Best practices

最佳实践

  1. Check
    rtk gain
    before reinstalling; it is the quickest way to distinguish the correct RTK from the wrong package.
  2. Use the lightest install path that meets the user's needs: Homebrew for convenience, install script for release binaries, Cargo for source-driven workflows.
  3. Treat
    rtk init -g
    as the normal path for hook-capable agents and local rules files as the normal path for Windsurf and Cline.
  4. Use
    rtk init --show
    after setup or upgrades so stale hook state is visible immediately.
  5. Remember that built-in read/search tools do not pass through shell hooks; switch to shell commands or direct
    rtk
    wrappers when token savings matter.
  6. Keep
    RTK_DISABLED=1
    in mind for one-off passthrough commands instead of uninstalling hooks.
  7. Re-run the installer plus
    rtk init
    after RTK upgrades because hook artifacts can change between releases.
  8. When users say "RTK is broken", separate installation correctness, hook registration, and actual command path before proposing a fix.
  1. 重新安装前先检查
    rtk gain
    ;这是区分正确RTK与错误包的最快方法。
  2. 使用满足用户需求的最轻量安装路径:Homebrew用于便捷性,安装脚本用于发布二进制文件,Cargo用于源码驱动的工作流。
  3. 对于支持钩子的代理,将
    rtk init -g
    视为常规设置路径;对于Windsurf和Cline,将本地规则文件视为常规设置路径。
  4. 设置或升级后使用
    rtk init --show
    ,以便立即查看失效的钩子状态。
  5. 记住内置的读取/搜索工具不会通过Shell钩子传递;当令牌节省很重要时,切换到Shell命令或直接的
    rtk
    包装器。
  6. 记住可使用
    RTK_DISABLED=1
    执行一次性直通命令,无需卸载钩子。
  7. RTK升级后重新运行安装器和
    rtk init
    ,因为钩子制品可能在不同版本间发生变化。
  8. 当用户说“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
  • 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仓库分支
  • 上游RTK项目