Scripts2026年7月18日·1 分钟阅读

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 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 27/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
CLI Tool
安装
Single
信任
信任等级:Established
入口
RTK CLI Proxy
安全暂存命令
npx -y tokrepo@latest install 27408fd9-8262-11f1-9bc6-00163e2b0d79 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产