RTK:在命令列前先壓縮輸出,替 AI 程式助手省下 80% token
title: RTK:在命令列前先壓縮輸出,替 AI 程式助手省下 80% token date: 2026-04-07 source: https://www.threads.com/@maoyang/post/DWyYUYsFAWR category: articles tags:
- RTK
- Rust Token Killer
- Claude Code
- Cursor
- Token Optimization
- CLI created: 2026-04-07 updated: 2026-04-07
RTK:在命令列前先壓縮輸出,替 AI 程式助手省下 80% token
概要
這篇 Threads 介紹一個很實用的 CLI 工具:RTK(Rust Token Killer)。它的核心想法很直接:當 Claude Code、Cursor 或其他 AI 程式助手執行 位於分支 main 尚未暫存以備提交的變更: (使用 "git add <檔案>..." 更新要提交的內容) (使用 "git restore <檔案>..." 捨棄工作區的改動) 修改: AGENTS.md
未追蹤的檔案: (使用 "git add <檔案>..." 以包含要提交的內容) .gitignore .openclaw/ BigIntTech_Feb.png BigIntTech_Jan.png HEARTBEAT.md IDENTITY.md MEMORY.md SOUL.md TOOLS.md USER.md agents/ commander-plan-2026-04-07-migration.md ctbc_11412_p1.png ctbc_11412_p2.png ctbc_11412_p3.png ctbc_11501_p1.png ctbc_11501_p2.png ctbc_11502_p1.png ctbc_11502_p2.png ctbc_cc_11412_p1.png ctbc_cc_11412_p2.png ctbc_cc_11412_p3.png ctbc_cc_11501_p1.png ctbc_cc_11501_p2.png ctbc_cc_11501_p3.png ctbc_cc_11502_p1.png ctbc_cc_11502_p2.png ctbc_cc_11502_p3.png dbs_202512_p1.png dbs_202512_p2.png dbs_202512_p3.png dbs_202601_p1.png dbs_202601_p2.png dbs_202601_p3.png dbs_202602_p1.png dbs_202602_p2.png dbs_202602_p3.png dbs_202602_p4.png google_service_account.json groups/ jina_key.jpg jina_page.jpg jina_revealed.jpg knowledge/kb-graph-design.md memory/ plans/ projects/ qijia-laravel-new/ receipts/ richmenu-elder.png scripts/ secrets/ skills/allen-kb/ tmp/ tmp_feds.pdf tmp_pdf/ travels/ venvs/ wallet-card.png wallet-payment.png wallet-settings.png wallet1.png
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")、、AGENTS.md BigIntTech_Feb.png BigIntTech_Jan.png HEARTBEAT.md IDENTITY.md MEMORY.md SOUL.md TOOLS.md USER.md agents commander-plan-2026-04-07-migration.md ctbc_11412_p1.png ctbc_11412_p2.png ctbc_11412_p3.png ctbc_11501_p1.png ctbc_11501_p2.png ctbc_11502_p1.png ctbc_11502_p2.png ctbc_cc_11412_p1.png ctbc_cc_11412_p2.png ctbc_cc_11412_p3.png ctbc_cc_11501_p1.png ctbc_cc_11501_p2.png ctbc_cc_11501_p3.png ctbc_cc_11502_p1.png ctbc_cc_11502_p2.png ctbc_cc_11502_p3.png dbs_202512_p1.png dbs_202512_p2.png dbs_202512_p3.png dbs_202601_p1.png dbs_202601_p2.png dbs_202601_p3.png dbs_202602_p1.png dbs_202602_p2.png dbs_202602_p3.png dbs_202602_p4.png google_service_account.json groups jina_key.jpg jina_page.jpg jina_revealed.jpg knowledge memory plans projects qijia-laravel-new receipts richmenu-elder.png scripts secrets skills tmp tmp_feds.pdf tmp_pdf travels venvs wallet-card.png wallet-payment.png wallet-settings.png wallet1.png、npm
Usage:
npm install install all the dependencies in your project npm install add the dependency to your project npm test run this project's tests npm run run the script named npm -h quick help on npm -l display usage info for all commands npm help search for help on npm help npm more involved overview
All commands:
access, adduser, audit, bugs, cache, ci, completion,
config, dedupe, deprecate, diff, dist-tag, docs, doctor,
edit, exec, explain, explore, find-dupes, fund, get, help,
help-search, init, install, install-ci-test, install-test,
link, ll, login, logout, ls, org, outdated, owner, pack,
ping, pkg, prefix, profile, prune, publish, query, rebuild,
repo, restart, root, run, sbom, search, set, shrinkwrap,
star, stars, start, stop, team, test, token, undeprecate,
uninstall, unpublish, unstar, update, version, view, whoami
Specify configs in the ini-formatted file: /Users/allenlin/.npmrc or on the command line via: npm --key=value
More configuration info: npm help config Configuration fields: npm help 7 config
npm@11.9.0 /Users/allenlin/.nvm/versions/node/v24.14.0/lib/node_modules/npm 等命令時,原始終端輸出通常非常冗長,這些文字若全數送進 LLM context,會快速消耗大量 token。RTK 的做法是在資訊進入 LLM 前先做壓縮與過濾,保留關鍵訊息、移除冗餘噪音。
作者引用的例子是: 原本可能有 15 行、約 200 tokens 的輸出,經過 RTK 過濾後只剩像 這樣的一行摘要。文中 claim 在 30 分鐘的 Claude Code session 中,可把約 118,000 tokens 壓縮到 23,900 tokens,平均節省約 80%。
重點
1. 問題不是模型不夠大,而是 CLI 噪音太多
很多 AI coding 的 token 浪費,其實不在需求本身,而是在各種命令列輸出:
- 位於分支 main 尚未暫存以備提交的變更: (使用 "git add <檔案>..." 更新要提交的內容) (使用 "git restore <檔案>..." 捨棄工作區的改動) 修改: AGENTS.md
未追蹤的檔案: (使用 "git add <檔案>..." 以包含要提交的內容) .gitignore .openclaw/ BigIntTech_Feb.png BigIntTech_Jan.png HEARTBEAT.md IDENTITY.md MEMORY.md SOUL.md TOOLS.md USER.md agents/ commander-plan-2026-04-07-migration.md ctbc_11412_p1.png ctbc_11412_p2.png ctbc_11412_p3.png ctbc_11501_p1.png ctbc_11501_p2.png ctbc_11502_p1.png ctbc_11502_p2.png ctbc_cc_11412_p1.png ctbc_cc_11412_p2.png ctbc_cc_11412_p3.png ctbc_cc_11501_p1.png ctbc_cc_11501_p2.png ctbc_cc_11501_p3.png ctbc_cc_11502_p1.png ctbc_cc_11502_p2.png ctbc_cc_11502_p3.png dbs_202512_p1.png dbs_202512_p2.png dbs_202512_p3.png dbs_202601_p1.png dbs_202601_p2.png dbs_202601_p3.png dbs_202602_p1.png dbs_202602_p2.png dbs_202602_p3.png dbs_202602_p4.png google_service_account.json groups/ jina_key.jpg jina_page.jpg jina_revealed.jpg knowledge/kb-graph-design.md memory/ plans/ projects/ qijia-laravel-new/ receipts/ richmenu-elder.png scripts/ secrets/ skills/allen-kb/ tmp/ tmp_feds.pdf tmp_pdf/ travels/ venvs/ wallet-card.png wallet-payment.png wallet-settings.png wallet1.png
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
- kubectl controls the Kubernetes cluster manager.
Find more information at: https://kubernetes.io/docs/reference/kubectl/
Basic Commands (Beginner): create Create a resource from a file or from stdin expose Take a replication controller, service, deployment or pod and expose it as a new Kubernetes service run Run a particular image on the cluster set Set specific features on objects
Basic Commands (Intermediate): explain Get documentation for a resource get Display one or many resources edit Edit a resource on the server delete Delete resources by file names, stdin, resources and names, or by resources and label selector
Deploy Commands: rollout Manage the rollout of a resource scale Set a new size for a deployment, replica set, or replication controller autoscale Auto-scale a deployment, replica set, stateful set, or replication controller
Cluster Management Commands: certificate Modify certificate resources cluster-info Display cluster information top Display resource (CPU/memory) usage cordon Mark node as unschedulable uncordon Mark node as schedulable drain Drain node in preparation for maintenance taint Update the taints on one or more nodes
Troubleshooting and Debugging Commands: describe Show details of a specific resource or group of resources logs Print the logs for a container in a pod attach Attach to a running container exec Execute a command in a container port-forward Forward one or more local ports to a pod proxy Run a proxy to the Kubernetes API server cp Copy files and directories to and from containers auth Inspect authorization debug Create debugging sessions for troubleshooting workloads and nodes events List events
Advanced Commands: diff Diff the live version against a would-be applied version apply Apply a configuration to a resource by file name or stdin patch Update fields of a resource replace Replace a resource by file name or stdin wait Experimental: Wait for a specific condition on one or many resources kustomize Build a kustomization target from a directory or URL
Settings Commands: label Update the labels on a resource annotate Update the annotations on a resource completion Output shell completion code for the specified shell (bash, zsh, fish, or powershell)
Subcommands provided by plugins:
Other Commands: api-resources Print the supported API resources on the server api-versions Print the supported API versions on the server, in the form of "group/version" config Modify kubeconfig files plugin Provides utilities for interacting with plugins version Print the client and server version information
Usage: kubectl [flags] [options]
Use "kubectl --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands).
這些輸出對人類來說可以掃讀,但對 LLM 而言,若不過濾就要完整吞進上下文,成本很高。
2. RTK 的價值在於「先壓縮再交給 AI」
RTK 不是優化模型,而是優化模型前面的輸入管線。這點很關鍵:
- 不必等更便宜的模型
- 不必等更大的 context window
- 先把沒必要的噪音擋掉
3. 支援工具鏈廣,適合實戰開發
根據貼文內容,RTK 支援超過 30 種命令的智慧過濾,涵蓋:
- Git / GitHub CLI
- Cargo
- npm / pnpm
- Docker
- Kubernetes
- Python(pytest / ruff / pip)
- Go(go test / golangci-lint)
如果描述屬實,這代表它不是概念 demo,而是瞄準真實 AI coding workflow 的中介層工具。
核心觀點
1. AI coding 成本優化的下一戰,在輸入前處理
大家常討論更好的模型、更大的 context、更便宜的 token,但像 RTK 這種工具提醒我們:如果輸入本身能變得更乾淨,很多成本其實可以直接在源頭省掉。
2. 這類工具很適合高頻 CLI 操作的工作流
如果一個 session 內會頻繁跑測試、看 Git 狀態、操作 Docker 或檢查 lint 結果,RTK 類工具很可能會比單純換模型更直接有效。
3. Token 優化正在從 prompt 工程延伸到系統層
以前談 token optimization,多半是在 prompt 怎麼寫。RTK 的出現說明現在優化已經往更底層走:從 prompt 前的終端輸入、資料管線、工具輸出開始治理。
資源
- 文章提及:https://repoinside.com/rtk-ai-token-killer
- Threads 原始分享:https://www.threads.com/@maoyang/post/DWyYUYsFAWR
一句話總結
RTK 值得注意的地方,不只是它省 token,而是它把 AI coding 的優化重點往前推了一層:先把工具輸出整理乾淨,再讓模型思考。