跳转到内容

Installation

此内容尚不支持你的语言。

Two unrelated projects share the name rtk. Make sure you install the right one:

  • Rust Token Killer (rtk-ai/rtk) — this project, a token-saving CLI proxy
  • Rust Type Kit (reachingforthejack/rtk) — a different tool for generating Rust types

The easiest way to verify you have the correct one: run rtk gain. It should display the savings dashboard. If it returns “command not found”, you either have the wrong package or RTK is not installed.

Terminal window
rtk --version # should print: rtk x.y.z
rtk gain # should show the savings dashboard

If both commands work, RTK is already installed. Skip to Project initialization.

Terminal window
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | sh

Installs to ~/.local/bin. Add it to your PATH if it is not there already:

Terminal window
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # or ~/.zshrc
Terminal window
brew install rtk-ai/tap/rtk
Terminal window
winget install rtk-ai.rtk
Terminal window
cargo install --git https://github.com/rtk-ai/rtk --branch master rtk

Pre-built binaries (Windows, Linux, macOS)

Section titled “Pre-built binaries (Windows, Linux, macOS)”

Download from GitHub releases:

  • macOS: rtk-x86_64-apple-darwin.tar.gz / rtk-aarch64-apple-darwin.tar.gz
  • Linux: rtk-x86_64-unknown-linux-musl.tar.gz / rtk-aarch64-unknown-linux-gnu.tar.gz
  • Windows: rtk-x86_64-pc-windows-msvc.zip

Windows users: Extract the zip and place rtk.exe in a directory on your PATH. Run RTK from Command Prompt, PowerShell, or Windows Terminal — do not double-click the .exe (it prints usage and exits immediately). See Windows below — the hook system works natively, no WSL required.

The same rtk binary built without the BUSL-1.1 compression engine — the hook rewrite system and every command filter, under Apache-2.0 alone. Pick this if your policy does not allow a source-available licence in the build.

Terminal window
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | RTK_EDITION=oss sh
brew install rtk-ai/tap/rtk-oss
cargo install --git https://github.com/rtk-ai/rtk --branch master rtk --no-default-features

Release assets are named rtk-oss-<target>, with rtk-oss Debian and RPM packages alongside. The binary is still called rtk, so hooks and scripts are unchanged — but the two editions conflict and cannot be installed together.

See Editions and Licensing for what the edition omits and where the licence boundary falls.

RTK works fully on native Windows. Since v0.37.2 the auto-rewrite hook runs as a native binary command (rtk hook claude) — no Unix shell, bash, or jq required — so commands are rewritten transparently in Command Prompt, PowerShell, and Windows Terminal, exactly as on Linux and macOS.

Prefer winget if you can — it handles PATH for you.

Terminal window
# 1. Download and extract rtk-x86_64-pc-windows-msvc.zip from releases
# 2. Add rtk.exe to your PATH (e.g. C:\Users\<you>\.local\bin)
# 3. Initialize - installs the native binary hook
rtk init -g

Upgrading from an older install? If you set RTK up before v0.37.2 you may still have the legacy rtk-rewrite.sh shell hook, which does need a Unix shell. Re-run rtk init -g to migrate to the native binary hook.

Prerequisites: some filters shell out to ripgrep (rg). Install it and keep it on your PATH to avoid Binary 'rg' not found on PATH warnings:

Terminal window
winget install BurntSushi.ripgrep.MSVC

WSL also works and behaves exactly like Linux:

Terminal window
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | sh
rtk init -g
FeatureNative WindowsWSL
Filters (cargo, git, …)FullFull
Auto-rewrite hookYes (native binary)Yes
rtk init -gHook modeHook mode
rtk gain / analyticsFullFull
Terminal window
rtk --version # rtk x.y.z
rtk gain # savings dashboard

If rtk gain fails but rtk --version succeeds, you installed Rust Type Kit by mistake. Uninstall it first:

Terminal window
cargo uninstall rtk

Then reinstall using one of the methods above.

For a single project, rtk init adds the RTK block to ./CLAUDE.md and a .rtk/filters.toml template, without installing a hook:

Terminal window
rtk init

To install the Claude Code hook (registered in ~/.claude/settings.json, applies to every project):

Terminal window
rtk init --global
Terminal window
rtk init -g --uninstall # remove hook, RTK.md, and settings.json entry
cargo uninstall rtk # remove binary (if installed via Cargo)
brew uninstall rtk # remove binary (if installed via Homebrew)
winget uninstall rtk-ai.rtk # remove binary (if installed via winget)