RTK: The Token Killer That Sits Between Your AI and the Terminal

Every time your AI agent runs a CLI command, it reads the full raw output β€” and that output is noisy. A simple git status returns 15 lines of boilerplate. A test failure from cargo test dumps 200+ lines. Over a 30-minute session, you're burning tens of thousands of tokens on noise the LLM doesn't need.

RTK (Rust Token Killer) is a single binary that intercepts that output, strips the noise, and hands back only what matters. Here's exactly how it works β€” and how to wire it up on Windows with Cursor.


The Problem: Raw CLI Output Is a Token Furnace

Consider what happens when an AI agent runs git status without RTK:

On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update staging area)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   src/components/Header.tsx
        modified:   src/pages/index.tsx

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        src/utils/helper.ts

no changes added to commit (use "git add" and/or "git commit -a")

~200 tokens. Half of it is git telling you how to use git. The AI doesn't need a tutorial β€” it needs the diff list.

With rtk git status:

M src/components/Header.tsx
M src/pages/index.tsx
? src/utils/helper.ts

~20 tokens. Same information, 90% smaller.


How RTK Works: The Proxy Pattern

without rtk Agent shell git git status ~200 tokens (raw output) with rtk Agent RTK git git status filter ~20 tokens (compressed)

RTK applies four strategies per command type:

  • Smart Filtering β€” removes comments, help text, boilerplate
  • Grouping β€” aggregates similar items (files by directory, errors by type)
  • Truncation β€” keeps relevant context, cuts redundancy
  • Deduplication β€” collapses repeated log lines with counts

The agent never sees the rewrite. It just receives a much shorter answer.


Real Savings Over a Session

Here's what a typical 30-minute Claude Code / Cursor session looks like with and without RTK:

CommandFrequencyStandardWith RTKSavings
git status10x3,000600-80%
cat / read20x40,00012,000-70%
cargo test / npm test5x25,0002,500-90%
grep / rg8x16,0003,200-80%
Total~118,000~23,900-80%

That's not just cost savings β€” it's a context window that stays clean longer, meaning the AI retains more useful history and makes fewer mistakes from lost context.


Installation on Windows

RTK ships as a single .exe. No installer, no runtime, no dependencies.

Step 1: Download rtk-x86_64-pc-windows-msvc.zip from the releases page, extract the rtk.exe.

Step 2: Place it somewhere permanent, e.g. C:\tools\rtk\

Step 3: Add that folder to your system PATH (search "Environment Variables" β†’ System Variables β†’ Path β†’ Edit β†’ New).

Step 4: Open a new terminal and verify:

rtk --version
# rtk 0.31.0

rtk gain
# No tracking data yet. Run some rtk commands to start tracking savings.

Wiring It Up with Cursor on Windows

RTK's bash hook β€” the mechanism that automatically rewrites git status to rtk git status β€” requires Unix. On Windows, it silently falls back to --claude-md mode, which writes instructions to a markdown file but doesn't intercept anything automatically.

rtk init -g --agent cursor

# Output:
# [warn] Hook-based mode requires Unix (macOS/Linux).
#        Windows: use --claude-md mode for full injection.
#        Falling back to --claude-md mode.
# [ok] Created C:\Users\you\.claude\CLAUDE.md with rtk instructions

The hook file (rtk-rewrite.sh) gets created but won't execute on Windows. To make RTK actually work with Cursor, you need to tell the agent explicitly via Cursor Rules.

Go to Cursor Settings β†’ Rules for AI and add:

When executing CLI commands, always use the rtk prefix:
- git status/diff/log/add/commit/push/pull β†’ rtk git ...
- cat/head/tail β†’ rtk read ...
- grep/rg β†’ rtk grep ...
- ls β†’ rtk ls ...
- cargo test/build/clippy β†’ rtk cargo ...
- npm test / pytest / go test β†’ rtk test ...
- When in doubt, prefix any CLI command with rtk.

This is a one-time setup. Cursor Agent will now use rtk across all sessions automatically β€” no bash hook needed.


Verify It's Working

Open a repo in Cursor, ask the agent to check git status. Watch the terminal panel β€” you should see rtk git status being called, not plain git status. Output will be the compressed 3-line version, not the 15-line boilerplate.

After a few commands, run:

rtk gain

You'll see a breakdown of tokens saved per command type, with running totals. Over a week of active development, the numbers get surprisingly large.


Worth It?

RTK is a zero-config, zero-dependency tool that does one thing well: it makes every CLI call cheaper for your AI agent. On Mac/Linux it's completely transparent via hooks. On Windows it needs a one-time Cursor Rule β€” a minor setup cost for a tool that then runs silently in the background indefinitely.

If you're doing serious AI-assisted development, it's one of the highest-ROI additions to your workflow.

β†’ github.com/rtk-ai/rtk

← Quay lαΊ‘i Blog
RTK: The Token Killer That Sits Between Your AI and the Terminal - Ginbok