ScriptsJul 18, 2026·3 min read

RTK — CLI Proxy That Cuts LLM Token Usage by 60-90%

RTK is a single-binary CLI proxy written in Rust that sits between your AI coding agent and shell commands, intelligently compressing tool outputs to reduce LLM token consumption by 60-90% with zero configuration.

Agent ready

Safe staging for this asset

This asset is staged first. The copied prompt tells the agent to inspect the staged files and ask before activating scripts, MCP config, or global config.

Stage only · 27/100Policy: stage
Agent surface
Any MCP/CLI agent
Kind
CLI Tool
Install
Single
Trust
Trust: Established
Entrypoint
RTK CLI Proxy
Safe staging command
npx -y tokrepo@latest install 27408fd9-8262-11f1-9bc6-00163e2b0d79 --target codex

Stages files first; activation requires review of the staged README and plan.

Introduction

RTK intercepts shell command output between your AI coding agent and the terminal, intelligently compressing verbose results so the LLM sees only what matters. Written in Rust as a single static binary with zero dependencies, it drops into any workflow without configuration changes.

What RTK Does

  • Intercepts CLI output and compresses it before it reaches the LLM context window
  • Reduces token consumption by 60-90% on common dev commands like git diff, find, and ls
  • Ships as a single Rust binary with no runtime dependencies
  • Works transparently with Claude Code, Cursor, Codex CLI, and other AI coding agents
  • Preserves semantic meaning while stripping noise, whitespace, and repetitive patterns

Architecture Overview

RTK acts as a lightweight proxy layer that wraps shell commands. When the AI agent issues a command, RTK executes it, captures stdout/stderr, applies format-aware compression heuristics (different strategies for JSON, diffs, directory listings, logs), and returns the compressed output. The compression is deterministic and lossless in terms of actionable information.

Self-Hosting & Configuration

  • Install with a one-line curl command or download the binary from GitHub releases
  • No configuration file required; works out of the box with sensible defaults
  • Set RTK_ENABLED=1 to enable proxy mode for all commands
  • Customize compression levels via RTK_LEVEL environment variable (1-5)
  • Supports allowlist and blocklist patterns for selective command interception

Key Features

  • Zero-config single binary with sub-millisecond overhead per command
  • Format-aware compression: understands git diffs, JSON, file trees, and log output
  • Reduces AI coding costs proportionally to token savings
  • Open source under MIT license with an active contributor community
  • Compatible with any AI agent that shells out to the terminal

Comparison with Similar Tools

  • Native context management — Built into some agents but lacks cross-tool portability
  • Manual prompt trimming — Requires user intervention; RTK automates it
  • Output piping with grep/sed — Loses structure; RTK preserves semantic content
  • LLM context window expansion — Costs more tokens; RTK reduces the need

FAQ

Q: Does RTK change the meaning of command output? A: No. RTK strips formatting noise and repetitive patterns but preserves all actionable information the LLM needs to make decisions.

Q: Does it work with any AI coding agent? A: Yes, it works with any tool that executes shell commands, including Claude Code, Cursor, Codex CLI, and custom agent setups.

Q: What is the performance overhead? A: Sub-millisecond per command invocation. The Rust binary is compiled to native code with no garbage collection pauses.

Q: Is it open source? A: Yes, RTK is fully open source under the MIT license.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets