DEV Community

Cover image for RTK: Cut Your AI Coding Bill by 80% With One CLI Tool
ArshTechPro
ArshTechPro

Posted on

RTK: Cut Your AI Coding Bill by 80% With One CLI Tool

If you use Claude Code, Cursor, Copilot, or any other AI coding assistant in your terminal, you are probably spending way more on tokens than you need to. RTK (Rust Token Killer) is an open-source CLI proxy that sits between your shell and your LLM and silently compresses what gets sent to the model — without changing how you work.

It has 39.5k stars on GitHub. It is worth understanding why.


The Problem It Solves

When an AI coding agent runs git status, the raw output can be 2,000 tokens. When it runs cargo test on a mid-sized project and a few tests fail, you are looking at 200+ lines of output — most of it passing tests you do not care about.

The agent reads all of it. You pay for all of it.

This happens dozens of times in a single session. A 30-minute Claude Code session on a TypeScript or Rust project can easily burn through 118,000 tokens just from routine shell commands — file reads, test runs, git operations, lint checks.

RTK intercepts those commands, applies smart filtering, and hands the model a compressed version that contains the same useful signal. According to the project's benchmarks, the same 30-minute session drops to around 23,900 tokens — an 80% reduction.


How It Actually Works

RTK is a CLI proxy. You prefix your commands with rtk, or you install a hook that does it transparently.

# Without RTK: git push outputs 15 lines (~200 tokens)
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
...

# With RTK: git push outputs 1 line (~10 tokens)
ok main
Enter fullscreen mode Exit fullscreen mode

Four strategies are applied depending on the command type:

  • Smart filtering — strips comments, whitespace, and boilerplate
  • Grouping — aggregates similar items, like files grouped by directory or errors grouped by type
  • Truncation — keeps the signal, drops the redundancy
  • Deduplication — collapses repeated log lines into a count

For test output specifically, RTK is particularly aggressive. cargo test on a failure goes from 200+ lines to roughly 20. You see which tests failed and why. The agent does not need to read the 13 passing tests to understand what went wrong.


Installation

RTK is a single Rust binary with no dependencies.

macOS (Homebrew):

brew install rtk
Enter fullscreen mode Exit fullscreen mode

Linux / macOS (curl):

curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
Enter fullscreen mode Exit fullscreen mode

Via Cargo:

cargo install --git https://github.com/rtk-ai/rtk
Enter fullscreen mode Exit fullscreen mode

One gotcha: there is another project called "rtk" (Rust Type Kit) on crates.io. If rtk gain fails after install, you got the wrong one. Use the --git flag above.

After install, connect it to your AI tool:

rtk init -g                    # Claude Code / Copilot
rtk init -g --agent cursor     # Cursor
rtk init -g --gemini           # Gemini CLI
rtk init --agent windsurf      # Windsurf
rtk init --agent cline         # Cline / Roo Code
Enter fullscreen mode Exit fullscreen mode

Restart your AI tool and that is it. Commands are automatically rewritten from git status to rtk git status before the model ever sees the output.


What Commands Are Supported

The coverage is broad. Here is a quick scan of what RTK knows how to compress:

Git:

rtk git status      # compact status
rtk git log -n 10   # one-line commits
rtk git diff        # condensed diff
rtk git push        # -> "ok main"
rtk git pull        # -> "ok 3 files +10 -2"
Enter fullscreen mode Exit fullscreen mode

Test runners (failures only — this is where the big savings come from):

rtk cargo test
rtk pytest
rtk go test
rtk jest
rtk vitest
rtk playwright test
rtk rspec
Enter fullscreen mode Exit fullscreen mode

Build and lint:

rtk tsc             # TypeScript errors grouped by file
rtk ruff check      # Python linting
rtk cargo clippy    # Rust lints
rtk golangci-lint run
Enter fullscreen mode Exit fullscreen mode

File operations:

rtk ls .            # token-optimized directory tree
rtk read file.rs    # smart file reading
rtk grep "pattern" .
Enter fullscreen mode Exit fullscreen mode

AWS, Docker, Kubernetes are also covered. The project lists 100+ supported commands.


The Auto-Rewrite Hook

The most useful feature is the hook. Once you run rtk init -g, a PreToolUse hook is installed in Claude Code (or your chosen agent) that transparently rewrites Bash commands before execution. The model never knows RTK is involved — it just receives smaller, cleaner output.

One thing worth knowing: the hook only intercepts Bash tool calls. Claude Code's built-in Read, Grep, and Glob tools bypass it. If you want RTK filtering for those workflows, use the shell equivalents (cat, rg, find) or call rtk read, rtk grep, rtk find directly.


Token Savings in Practice

Here is the table from the project's README, representing a 30-minute session on a medium-sized project:

Command Frequency Standard RTK Savings
ls / tree 10x 2,000 400 -80%
cat / read 20x 40,000 12,000 -70%
grep / rg 8x 16,000 3,200 -80%
git status 10x 3,000 600 -80%
git diff 5x 10,000 2,500 -75%
cargo test / npm test 5x 25,000 2,500 -90%
pytest 4x 8,000 800 -90%
Total ~118,000 ~23,900 -80%

You can see your own savings with:

rtk gain              # summary stats
rtk gain --graph      # ASCII graph of the last 30 days
rtk gain --history    # recent command history
Enter fullscreen mode Exit fullscreen mode

Is It Worth It?

The honest case for trying it:

  • Zero friction to install and zero changes to your workflow after the hook is set up.
  • The savings are real and verifiable — you can check them yourself with rtk gain.
  • 39.5k stars and active development (141 releases, v0.38.0 as of late April 2026) suggest this is not an abandoned project.
  • It is open-source (MIT), written in Rust, and ships as a single binary with no dependencies. The attack surface is minimal.

The honest caveats:

  • The benchmark numbers (60-90% savings) are estimates based on medium-sized projects. Real savings depend heavily on how you work and what you are building.
  • The hook only works on Bash calls. If your agent leans heavily on its native file-reading tools, a portion of your token usage is unaffected.
  • On Windows, you get full filter support but no auto-rewrite hook unless you use WSL. Native Windows gets a CLAUDE.md fallback mode instead.
  • When a command fails, RTK saves the full unfiltered output to disk so the model can read it — a thoughtful design, but worth being aware of if you are working with sensitive output.
  • If RTK's filter for a specific command is overly aggressive, it could in theory strip context the agent needed. The rtk discover command helps you find cases where savings were unexpectedly low, which can be a signal that something went wrong.

Quick Summary

RTK is a thin, fast CLI proxy that compresses the output of 100+ common dev commands before they reach your LLM. It installs in one command, hooks into your agent transparently, and saves you a measurable amount on token usage — particularly for test runners and git operations.

GitHub: github.com/rtk-ai/rtk


Top comments (1)

Collapse
 
arshtechpro profile image
ArshTechPro

RTK is a thin, fast CLI proxy that compresses the output of 100+ common dev commands before they reach your LLM. It installs in one command, hooks into your agent transparently, and saves you a measurable amount on token usage — particularly for test runners and git operations.