Back to Work
AILLMRust

RTK — Token Optimizer for AI Coding Agents

A Rust CLI proxy that cuts 60–90% of the tokens AI coding agents burn on dev-command output, making long agent sessions cheaper and more reliable

Client

Internal tooling

Role

Creator

Timeline

Ongoing

Tech Stack

AILLMRust

Project Overview

AI coding agents like Claude Code run shell commands constantly — git status, test suites, linters, build tools — and every line of output lands in the model’s context window. Most of that output is noise the model doesn’t need, but you pay for it in tokens, latency, and shortened sessions.

RTK (Rust Token Killer) is a CLI proxy I built to fix that. It intercepts dev commands, executes them, and returns a filtered, compact version of the output — keeping every piece of signal (errors, diffs, failures) while discarding the boilerplate.

The Challenge

  • Agent sessions die early because command output floods the context window
  • Verbose tools (test runners, package managers, git) repeat the same boilerplate thousands of times per day
  • Filtering must be lossless where it matters: a swallowed error message is worse than a long one

What I Built

  • A Rust CLI proxy with per-command output filters for the highest-traffic dev tools (git, test runners, linters, package managers)
  • Transparent hook integration with Claude Code: a hook rewrites git status to rtk git status automatically, so the agent needs zero awareness of the tool
  • Savings analytics (rtk gain): tracks tokens saved per command and per session, with history
  • An escape hatch (rtk proxy <cmd>): raw unfiltered execution for debugging, so filtering is never a black box

Outcomes

  • 60–90% token savings on dev-command output, measured per command by the tool itself
  • Longer productive agent sessions before context exhaustion, at lower API cost
  • Used daily in my own AI-augmented consulting workflow — this tool is part of how I ship client work faster

Technologies Used

  • Language: Rust
  • Integration: Claude Code hooks (PreToolUse command rewriting)
  • Analytics: Built-in per-command savings tracking