Skip to content

What is RTK? Rust Token Killer for AI Coding Tools

I burned through my API budget in three days. The culprit? Shell command output.

Every time I asked my AI coding assistant to check a directory, run a build, or inspect logs, hundreds of tokens vanished into verbose output I barely needed. A simple ls -la could consume 50+ tokens. npm install? Hundreds. And don’t get me started on build errors that scrolled for pages.

The AI didn’t care about every file permission or every line of a successful install. It just needed to know: did it work? What files exist? What errors appeared?

I needed a way to compress this noise before it hit my token limit.

The Problem with Shell Output

Here’s what happened when I ran a typical development workflow:

Me: Check the project structure and run the tests
AI: [Runs ls -la]
[Token explosion: 150+ tokens of file listings]
[Runs npm test]
[Another 200+ tokens of test output]
[Context window filling up...]
Me: Now fix the failing tests
AI: I'm sorry, we're running low on context...

The context window filled with noise, not signal. Every shell command became a token tax.

What RTK Does

RTK (Rust Token Killer) sits between your AI assistant and the shell, intercepting commands and compressing their output:

+-----------------+
| AI Assistant | (OpenCode, Claude Code, etc.)
+--------+--------+
|
| Shell Tool Call
v
+--------+--------+
| RTK Plugin | <-- Intercepts here
+--------+--------+
|
| Wrapped Execution
v
+--------+--------+
| Shell Command | (runs inside RTK environment)
+--------+--------+
|
| Compressed Output (80-90% smaller)
v
+--------+--------+
| AI Assistant | Receives condensed info
+-----------------+

Instead of seeing:

total 64
drwxr-xr-x 12 user staff 384 Mar 14 10:00 .
drwxr-xr-x 8 user staff 256 Mar 14 09:45 ..
-rw-r--r-- 1 user staff 1024 Mar 14 10:00 package.json
-rw-r--r-- 1 user staff 2048 Mar 14 10:00 README.md
drwxr-xr-x 10 user staff 320 Mar 14 10:00 src
...
(20 more lines)

The AI sees something like:

. src/ package.json README.md

Same information, fraction of the tokens.

How It Works

The compression isn’t random. RTK applies intelligent rules:

File Listings: Removes permissions, ownership, timestamps. Shows only names.

Build Output: Collapses success messages. Highlights only errors and warnings.

Logs: Strips timestamps, hostnames, process IDs. Keeps the message.

Package Installs: Summarizes added/removed packages. Skips the progress bars.

The key insight: AI assistants don’t read every character. They extract patterns and meaning. RTK preserves the meaning while discarding the formatting overhead.

Setting Up RTK with OpenCode

For OpenCode users (v0.29.0+), RTK support is built-in:

Option 1: Use the bundled version

Terminal window
# RTK is included in OpenCode v0.29.0+
# Just enable it in your config

Option 2: Manual installation

Terminal window
# Clone the repository
git clone https://github.com/evalplus/rtk
# Copy the plugin to your OpenCode plugins folder
cp rtk/rtk.ts ~/.opencode/plugins/

I went with Option 1 since I was already on v0.29.0. Zero configuration, immediate savings.

Real Results

After enabling RTK, I tracked my token usage over a week:

MetricBefore RTKAfter RTKSavings
Avg tokens/session45,00012,00073%
Shell output tokens18,0002,10088%
Cost/day$3.20$0.8573%
Context remainingOften depletedUsually 40%+Significant

The numbers matched the Reddit discussion claims: 80-90% reduction on shell output specifically. Overall token savings landed around 70-75% since not every message involves shell commands.

When RTK Helps Most

Best cases:

  • Large codebase navigation (lots of ls, find, grep)
  • Build and test workflows (verbose output)
  • Package management (npm, pip, cargo)
  • Log analysis and debugging

Less impact:

  • Pure code discussions (no shell commands)
  • Small projects (few files)
  • Quick questions (minimal tool usage)

I noticed the biggest savings during refactoring sessions where the AI constantly checked file structures and ran tests. Those sessions went from budget-breaking to sustainable.

Why This Matters

Token costs aren’t just about money—they’re about context. Every token spent on verbose output is a token not available for:

  • Remembering earlier discussion points
  • Understanding complex code patterns
  • Maintaining coherent multi-step reasoning

RTK isn’t just saving me dollars. It’s giving my AI assistant more room to think.

RTK isn’t the only optimization technique, but it’s uniquely positioned:

ApproachScopeEffort
RTKShell output onlyZero config
Custom promptsAll interactionsManual tuning
Output parsersPost-processingCode changes
Token cachingRepeated contextInfrastructure

RTK wins on simplicity. Install it, forget it, save tokens automatically.

Limitations

RTK isn’t perfect:

  1. Over-compression: Sometimes strips too much. If you need exact file permissions or timestamps, you might miss them.

  2. Tool-specific: Only works on shell output. Won’t compress file reads or API responses.

  3. Debugging difficulty: Compressed output can obscure issues when you’re trying to debug the AI’s actions.

I’ve learned to disable RTK temporarily when I need to see exactly what the AI saw. For most workflows, though, the compression is transparent.

Bottom Line

RTK solves a real problem with minimal friction. If you use AI coding assistants heavily and notice context filling with shell output, it’s worth the setup.

For OpenCode users on v0.29.0+, there’s no reason not to enable it. For others, the plugin approach works across different AI tools—it just requires manual integration.

The 80-90% compression claims are accurate, at least for shell-heavy sessions. Your mileage varies based on how often your AI runs commands versus writing code directly.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments