如何省token?--- RTK ,input 数据压缩

Claude Code Token 烧得太快?这8个方案帮你立省90%!前言 token越来越贵了,而且高等级模型消耗的 - 掘金

 

6. 数据预处理

利用 PreToolUse 钩子(类似于请求拦截器),在 Claude 执行操作前,对输入的数据进行处理、压缩,从而达到减小token使用量。

示例:使用 rtk

rtk会拦截并重写 Bash 命令的输出,比如 git diff 只展示文件差异的核心摘要。

1.rtk安装(Windows)

1.访问 github.com/rtk-ai/rtk/…

2.在页面中找到类似 rtk-x86_64-pc-windows-msvc.zip 的文件,下载到本地

3.将下载的压缩包解压,放在一个你方便管理的专属文件夹,例如 D:\Develop\rtk

4.在用户变量和系统变量列表中找到 Path,选中后点击编辑,新增 D:\Develop\rtk

 


RTK(Rust Token Killer)

官网标语:

Compress command outputs before they reach the LLM context window.(在终端输出进入 LLM 上下文之前进行压缩) [rtk-ai.app]

它是一个专门为:

  • Claude Code
  • GitHub Copilot
  • Codex
  • Cursor
  • Cline
  • Gemini CLI
  • Aider
  • Windsurf

等 AI 编程工具设计的 Token 优化工具。

 

Copilot

RTK

Shell
 
 
RTK

减少命令输出Token
 
/compact

减少会话历史Token
 
Vibe Usage

监控是否真的降下来了

 

posted @ 2026-08-05 14:47  PanPan003  阅读(9)  评论(0)    收藏  举报