欣淇
发布于 2026-05-16 / 0 阅读
0
0

⚡ RTK (Rust Token Killer):48.6k Stars 的 CLI 代理,让你的 AI Coding Agent Token 消耗直降 80% / RTK: The Rust CLI Proxy That Slashes AI Agent Token Usage by 60-90%

⚡ RTK (Rust Token Killer):48.6k Stars 的 CLI 代理,让你的 AI Coding Agent Token 消耗直降 80% / RTK: The Rust CLI Proxy That Slashes AI Agent Token Usage by 60-90%

每天用 Claude Code 写代码,一个月光 Token 费就烧掉几百刀?RTK 说「不用」。

RTK (Rust Token Killer) 是一个高性能 CLI 代理,48.6k Stars,Rust 写的单个二进制文件,零依赖。它放在你的 shell 和 AI 工具之间,实时过滤压缩命令输出——平均省 80% Token,一次 30 分钟 Claude Code 会话从 ~118K token 直降到 ~24K。

一行命令装上

brew install rtk
# 或者
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh

装完验证:

rtk --version   # 应该看到 rtk 0.28.2
rtk gain        # 显示 Token 节省统计

给你的 AI 工具接上

rtk init -g                     # Claude Code / Copilot(默认)
rtk init -g --gemini            # Gemini CLI
rtk init -g --codex             # Codex (OpenAI)
rtk init --agent cursor         # Cursor
rtk init --agent hermes         # Hermes

重启你的 AI 工具,接下来执行 git status 就会自动走 RTK 管道——返回的只有几行压缩结果,不再有几百行废话。

省在哪里?

看这张表就明白了(一次 30 分钟 Claude Code 会话的数据):

操作 频率 常规 Token RTK 后 节省
ls / tree 10次 2,000 400 -80%
cat / 读文件 20次 40,000 12,000 -70%
grep / rg 8次 16,000 3,200 -80%
git diff 5次 10,000 2,500 -75%
cargo test / npm test 5次 25,000 2,500 -90%
合计 ~118,000 ~23,900 -80%

日常用法

# 文件操作
rtk ls .                        # 压缩目录树
rtk read file.rs                # 智能读文件
rtk find "*.rs" .               # 紧凑查找结果

# Git 操作
rtk git status                  # 一行搞定
rtk git push                    # 输出仅 "ok main"
rtk git commit -m "msg"         # 输出仅 "ok abc1234"

# 测试和构建
rtk pytest                      # 只看失败的测试
rtk cargo test                  # -90% 输出
rtk cargo build                 # 只保留关键信息

# Docker / K8s
rtk docker ps                   # 压缩容器列表
rtk kubectl pods                # 紧凑 Pod 列表

原理

   RTK:
  Claude Code --git status-->  shell  -->  git
    ^                                    |
    |         ~2,000 tokens  (原始输出)    |
    +------------------------------------+

   RTK:
  Claude Code --git status-->  RTK  -->  git
    ^                      |           |
    |   ~200 tokens        | 过滤压缩   |
    +----------------------+-----------+

四条策略:智能过滤(去注释/空白)、分组聚合(文件按目录、错误按类型)、截断(保留关键上下文)、去重(重复行标计数)。

一个 Rust 二进制,<10ms 额外开销,支持 100+ 命令,覆盖 git、npm/cargo/go/pytest、docker/kubectl、AWS CLI。它甚至支持 13 种 AI 工具——Claude Code、Copilot、Cursor、Gemini CLI、Codex、Windsurf、Hermes 全家桶全覆盖。

RTK 适配工具列表

工具 安装命令 方式
Claude Code rtk init -g Hook 透明拦截
GitHub Copilot rtk init -g --copilot Hook 透明拦截
Gemini CLI rtk init -g --gemini BeforeTool hook
Codex rtk init -g --codex AGENTS.md 指令注入
Cursor rtk init -g --agent cursor preToolUse hook
Hermes rtk init --agent hermes Python 插件适配

RTK is a high-performance CLI proxy (48.6k★) that sits between your shell and AI coding tools, filtering and compressing command outputs to slash token consumption by 60-90%. Single Rust binary, zero dependencies, <10ms overhead, 100+ supported commands.

How it works: Instead of piping raw git status (~2,000 tokens) into Claude Code, RTK intercepts it and returns a compact version (~200 tokens). Same for cat, grep, cargo test, docker ps, kubectl pods — every command gets optimized.

Quick start:

brew install rtk
rtk init -g           # Hook into Claude Code
# Restart your AI tool and you're done

Token savings in a 30-min session: 118K → 24K tokens (-80%). Supports 13 AI tools including Claude Code, Copilot, Gemini CLI, Codex, Cursor, Windsurf, and Hermes.

GitHub: https://github.com/rtk-ai/rtk
Web: https://www.rtk-ai.app


评论