Repo Dev Tools

rtk-ai/rtk

Rust CLI proxy that filters and compresses shell command output before your AI agent reads it, cutting up to 90% of bash output across 100+ commands.

  • 82.8k GitHub stars
  • Rust
  • ⚖️ Apache-2.0
  • 🎯 Beginner
brew install rtk
rtk-ai/rtk preview image

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

  1. Install with Homebrew

    The README's recommended install method.

    bash
    brew install rtk
  2. Verify installation

    Check the version and the savings dashboard. If rtk gain fails, you may have the wrong package (a different project named "rtk" exists on crates.io), so use the cargo install --git method instead.

    bash
    rtk --version   # Should show "rtk 0.28.2"
    rtk gain        # Should show the savings dashboard
  3. Install 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, --codex or --agent cursor.

    bash
    rtk init -g                     # Claude Code / Copilot (default)
  4. Alternative: install from source via Cargo

    The README says to use this instead of the crates.io package name, which collides with another project.

    bash
    cargo install --git https://github.com/rtk-ai/rtk

Examples

Compact git and file commands

bash
bash
rtk 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

bash
bash
rtk 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

bash
bash
rtk gain                        # Summary stats
rtk gain --graph                # ASCII graph (last 30 days)
rtk discover                    # Find missed savings opportunities

What it does: Analytics commands show how much output RTK has trimmed and where more savings are possible.

Configure hook exclusions

toml
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) | disabled

What 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 rtk explicitly
  • 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