What it is
RTK (Rust Token Killer) is a single Rust binary that intercepts shell commands and compresses their output before it reaches your LLM context. It uses smart filtering, grouping, truncation and deduplication, tuned per command type. Hooks or plugins for supported AI coding tools rewrite commands such as git status to rtk git status automatically. The README reports under 10ms of overhead.
Who it's for
- Developers using AI coding agents (Claude Code, Copilot, Cursor, Gemini CLI, Codex and others) who want less noisy bash output in context
- Teams who want to track token savings through a built-in analytics dashboard
- Windows, macOS and Linux users, including WSL
Requirements
Requirements
- One of the supported AI coding tools, if you want automatic command rewriting
- Restart your AI tool after running
rtk init - On Windows, ripgrep (
rg) on PATH, because some filters shell out to it
Setup
Install with Homebrew
The README's recommended install method.
bashbrew install rtkVerify installation
Check the version and the savings dashboard. If
rtk gainfails, you may have the wrong package (a different project named "rtk" exists on crates.io), so use thecargo install --gitmethod instead.bashrtk --version # Should show "rtk 0.28.2" rtk gain # Should show the savings dashboardInstall the hook for your AI tool
Run init for Claude Code / Copilot (the default), then restart your AI tool. Other agents use flags such as
--gemini,--codexor--agent cursor.bashrtk init -g # Claude Code / Copilot (default)Alternative: install from source via Cargo
The README says to use this instead of the crates.io package name, which collides with another project.
bashcargo install --git https://github.com/rtk-ai/rtk
Examples
Compact git and file commands
bashrtk git status # Compact status
rtk git log -n 10 # One-line commits
rtk git push # -> "ok main"
rtk read file.rs -l aggressive # Signatures only (strips bodies)What it does: Calls RTK directly to get condensed output for common git and file operations.
Run tests with failures only
bashrtk pytest # Python tests (-90%)
rtk cargo test # Cargo tests (-90%)
rtk test <cmd> [args...] # Direct argv execution, failures only (-90%)What it does: Test runner wrappers show failures only and collapse passing tests to a count.
Review token savings
bashrtk gain # Summary stats
rtk gain --graph # ASCII graph (last 30 days)
rtk discover # Find missed savings opportunitiesWhat it does: Analytics commands show how much output RTK has trimmed and where more savings are possible.
Configure hook exclusions
toml[hooks]
exclude_commands = ["curl", "playwright"] # skip rewrite for these (matches `npx playwright` too)
suppress_hook_warning = false # suppress the missing-hook warning only
[retriever]
mode = "sqlite" # sqlite (default) | tee (legacy files) | disabledWhat it does: Goes in ~/.config/rtk/config.toml (macOS: ~/Library/Application Support/rtk/config.toml) to skip rewriting selected commands and choose the output-recovery mode.
Pros & cons
Pros
- Pro:Single Rust binary with 100+ supported commands and under 10ms overhead
- Pro:Auto-rewrite hook means the agent gets compact output without calling
rtkexplicitly - Pro:Integrates with 18 AI coding tools, including Claude Code, Cursor, Gemini CLI and Codex
- Pro:Built-in analytics (
rtk gain,rtk discover) and saved full output for failed commands that the LLM can recall
Cons
- Con:The hook only applies to Bash tool calls; built-in tools like Read, Grep and Glob bypass it
- Con:The reduction applies to bash output, not your bill, because bash output is only one part of input tokens
- Con:Reported token counts are estimated as bytes/4, so percentages are reliable but absolute numbers are approximate
Images
