AI资讯大全AIPPXP.CN搜索 ↗
工具介绍 · 免费好用

RTK (Rust Token Killer): Cut the command output read by the AI assistant by up to 90%, single file Rust binary, 80,000 starsRTK(Rust Token Killer):把 AI 助手读到的命令输出砍掉最多九成,单文件 Rust 二进制、8 万星

People who write code with Claude Code, Codex, and Cursor are distressed by tokens: a git status, a test failure log, thousands of tokens are poured into the context, the money is spent, and the window is full. RTK is an "output scissor" written in Rust - it inserts a layer of proxy between the command and the model, and filters, groups, truncates, deduplicates and hands over the output of more than 100 commands such as ls, grep, git, test, build, Docker, kubectl, etc. to the model. Officially, it can reduce the bash output by up to 90%, with a single overhead of less than 10 milliseconds.

用 Claude Code、Codex、Cursor 写代码的人都心疼过 token:一条 git status、一次测试失败日志,动辄几千上万 token 灌进上下文,钱花了、窗口也被占满。RTK 是一把用 Rust 写的「输出剪刀」——它在命令与模型之间插一层代理,把 ls、grep、git、测试、构建、Docker、kubectl 等 100 多个命令的输出做过滤、分组、截断、去重后再交给模型,官方称最高可减少约九成的 bash 输出,单次开销低于 10 毫秒。

2026-10-09 更新 · 免费
RTK(Rust Token Killer):把 AI 助手读到的命令输出砍掉最多九成,单文件 Rust 二进制、8 万星

Why Do You Need It?为什么需要它

A large part of the AI programming assistant's input token is not the prompt you wrote, but the original output it reads back after running the command in the background.

A git diff can be hundreds of lines, a test failure with a full stack, and a Docker log that flushes tens of thousands of lines at a time - all crammed into a context window.

RTK's idea is to "sift through the model before seeing it": only the conclusive information is retained, the noise is discarded locally, the model can still understand, and the window is saved.

中文

AI 编程助手的输入 token 里,很大一块不是你写的提示词,而是它在后台跑命令后读回来的原始输出。

一条 git diff 可能是几百行,一次测试失败会带上完整堆栈,一次 Docker 日志甚至会刷屏几万行——这些全都会被塞进上下文窗口。

RTK 的思路是「在模型看到之前先筛一遍」:只保留结论性的信息,把噪声在本地丢掉,模型照样能理解,窗口却省下来了。

What it does specifically for compression它具体做什么压缩

File class: ls and tree output changed to compact tree with number of files, cat and read replaced full text with signature and structure, grep and rg grouped by files and truncated overlong lines.

Git class: git status becomes compact statistics, git log only leaves hashes, authors and topics, git push and git commit only return one line confirmation.

Testing and building: cargo test, npm test, pytest, go test, etc. Only the failed items are retained, and the passed use cases are folded into a count.

O&M and containers: docker ps, docker images, kubectl pods, aws series commands have done field clipping and log deduplication, and will filter out key class information.

Officially, there are four sets of common strategies: intelligent filtering denoising, similarity group aggregation, on-demand truncation, and repetitive row folding counting.

中文

文件类:ls 与 tree 输出改成带文件数的紧凑树形,cat 与 read 以签名和结构代替全文,grep 与 rg 按文件分组并截断超长行。

Git 类:git status 变紧凑统计,git log 只留哈希、作者与主题,git push 与 git commit 只回一行确认。

测试与构建:cargo test、npm test、pytest、go test 等只保留失败项,通过的用例折叠成一个计数。

运维与容器:docker ps、docker images、kubectl pods、aws 系列命令都做了字段裁剪与日志去重,并会过滤掉密钥类信息。

官方给出四套通用策略:智能过滤去噪、相似项分组聚合、按需截断、重复行折叠计数。

它具体做什么压缩

How to access AI tools怎么接入 AI 工具

Execute the initialization command once: rtk init -g For Claude Code and Copilot, add --gemini, --codex, --agent cursor, --agent windsurf and other parameters to switch the target tool.

After initialization, it writes the hook, and the git status command is automatically rewritten to rtk git status. The model gets the compressed output, so you don't need to change your habits manually.

Note that the hook only takes effect for Bash tool calls; the Read, Grep, and Glob built into Claude Code do not go through Bash. If you want to save this part of the token, use the shell command or directly call rtk read and rtk grep.

You can always execute rtk gain to open the savings board to see how much output and tokens are currently saved.

中文

执行一次初始化命令即可:rtk init -g 面向 Claude Code 与 Copilot,加 --gemini、--codex、--agent cursor、--agent windsurf 等参数可切换目标工具。

初始化后它会写入钩子,把 git status 这类命令自动改写成 rtk git status,模型拿到的就是压缩后的输出,不需要你手动改习惯。

注意钩子只对 Bash 工具调用生效;Claude Code 内置的 Read、Grep、Glob 不经过 Bash,想省这部分 token 就改用 shell 命令或直接调 rtk read、rtk grep。

随时可以执行 rtk gain 打开节省看板,查看当前累计省下多少输出与 token。

Download and Installation Instructions下载与安装说明

Below is the complete source code package for the official repository. Users who have installed the Rust toolchain can install it directly from the source code at cargo install --git https://github.com/rtk-ai/rtk.

There are more options that you don't want to compile: macOS user brew install rtk, Windows user winget install rtk-ai.rtk, Linux and macOS can also be installed to ~/.local/bin with one click using the official install.sh script.

The official Releases page also provides precompiled binaries for Windows, macOS, and Linux. After downloading the Windows version, put rtk.exe into path. Be careful not to double-click in the Explorer.

After the installation is completed, perform rtk --version and rtk gain verification; if you are prompted that the command cannot be found, it means that the installation directory has not been added to path.

Beware of items with the same name: there is another Rustin Type Kit called rtk on crates.io. If rtk gain reports an error, it is likely to be the wrong package.

中文

下面提供的是官方仓库的完整源码包。已装 Rust 工具链的用户可以直接 cargo install --git https://github.com/rtk-ai/rtk 从源码安装。

不想编译的选择更多:macOS 用户 brew install rtk,Windows 用户 winget install rtk-ai.rtk,Linux 与 macOS 也可以用官方 install.sh 脚本一键装到 ~/.local/bin。

官方 Releases 页面同时提供 Windows、macOS、Linux 的预编译二进制,Windows 版下载后把 rtk.exe 放进 PATH 即可,注意不要在资源管理器里双击运行。

安装完成后执行 rtk --version 与 rtk gain 验证;若提示找不到命令,说明安装目录还没加入 PATH。

小心中招同名项目:crates.io 上另有一个叫 rtk 的 Rustin Type Kit,如果 rtk gain 报错,多半是装错了包。

Use reminder使用提醒

Officially clarified: the reduction is the bash output, which does not mean that the bill is directly reduced by 90% - the input token also contains system prompts and conversation history, and the output token is completely unaffected. The number it reports is estimated in bytes divided by four, the percentage is reliable, and the absolute value is only approximate. The tool will override your shell command execution path, it is recommended to try it out in a non-core project first. This article is compiled from self-disclosure materials. The resources are for learning and communication only. Please follow the project Apache-2.0 license.

中文

官方明确说明:减少的是 bash 输出量,不等于账单直接降九成——输入 token 还包含系统提示与对话历史,输出 token 更是完全不受影响。它报告的数字按字节除以四估算,百分比可靠、绝对值只是近似。工具会改写你的 shell 命令执行路径,建议先在非核心项目里试用。本文整理自公开资料,资源仅供学习交流,请遵循项目 Apache-2.0 许可。

资源下载 · Download

⬇ Download · 点击下载:RTK 完整源码包(default 分支快照)(约 1.9 MB)

来自 GitHub 开源仓库 rtk-ai/rtk 默认分支源码(Apache-2.0 许可),含 Rust 全部源码与文档;可用 cargo install --git 编译,或改用官方预编译二进制 / brew / winget 安装

0阅读0 条评论

阅读与点赞数据保存在你的浏览器本地,欢迎留下你的想法。

评论 文明发言,让讨论更有价值

正能量公益广告今日正能量学一点,用一点;今天种下的种子,会长成明天的能力。去免费下载专区 →广告