<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>RTK on KnightLi Blog</title>
        <link>https://knightli.com/en/tags/rtk/</link>
        <description>Recent content in RTK on KnightLi Blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Wed, 27 May 2026 13:52:01 +0800</lastBuildDate><atom:link href="https://knightli.com/en/tags/rtk/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>RTK: A CLI Proxy That Saves Tokens for AI Coding Agents</title>
        <link>https://knightli.com/en/2026/05/27/rtk-ai-cli-proxy-token-savings/</link>
        <pubDate>Wed, 27 May 2026 13:52:01 +0800</pubDate>
        
        <guid>https://knightli.com/en/2026/05/27/rtk-ai-cli-proxy-token-savings/</guid>
        <description>&lt;p&gt;&lt;code&gt;rtk-ai/rtk&lt;/code&gt; is a command-line proxy for AI coding agents. The idea is straightforward: many agents repeatedly call &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;cat&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;git status&lt;/code&gt;, &lt;code&gt;git diff&lt;/code&gt;, test commands, and build commands while working on a project, and the raw output from those commands is often long and repetitive. RTK filters and compresses command output before it enters the LLM context, so the model sees shorter and more useful results.&lt;/p&gt;
&lt;p&gt;Project: &lt;a class=&#34;link&#34; href=&#34;https://github.com/rtk-ai/rtk&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;rtk-ai/rtk&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;what-problem-it-solves&#34;&gt;What Problem It Solves
&lt;/h2&gt;&lt;p&gt;The real cost of AI coding tools is not only the number of model calls. It is also the useless information pushed into the context window.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ls -la&lt;/code&gt; may output lots of permissions, timestamps, and irrelevant files.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git diff&lt;/code&gt; may include a lot of repeated context.&lt;/li&gt;
&lt;li&gt;When &lt;code&gt;pytest&lt;/code&gt;, &lt;code&gt;cargo test&lt;/code&gt;, or &lt;code&gt;npm test&lt;/code&gt; fails, the important part is the failing case and stack trace, not every passing case.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docker ps&lt;/code&gt;, &lt;code&gt;kubectl pods&lt;/code&gt;, and &lt;code&gt;aws&lt;/code&gt; commands often expose many fields, while the agent only needs a few key details.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If all of that output enters the model context unchanged, it burns tokens quickly. RTK does not replace those commands. It adds a compression layer between them and the AI coding agent.&lt;/p&gt;
&lt;h2 id=&#34;how-rtk-works&#34;&gt;How RTK Works
&lt;/h2&gt;&lt;p&gt;RTK&amp;rsquo;s README positions it as a tool that filters and compresses command results before they reach the LLM context. It is a single Rust binary, supports many common development commands, and emphasizes low overhead.&lt;/p&gt;
&lt;p&gt;It mainly applies four strategies:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Smart Filtering&lt;/strong&gt;: removes comments, whitespace, boilerplate, and low-value noise.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Grouping&lt;/strong&gt;: aggregates similar items, such as by directory, error type, or status.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Truncation&lt;/strong&gt;: keeps the relevant context and cuts repeated or unimportant parts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deduplication&lt;/strong&gt;: collapses repeated log lines into shorter counted output.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;From the agent&amp;rsquo;s perspective, the commands are still familiar development commands. The difference is that the result returned to the model is shorter.&lt;/p&gt;
&lt;h2 id=&#34;supported-commands&#34;&gt;Supported Commands
&lt;/h2&gt;&lt;p&gt;RTK focuses on everyday development workflows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Files: &lt;code&gt;rtk ls&lt;/code&gt;, &lt;code&gt;rtk read&lt;/code&gt;, &lt;code&gt;rtk find&lt;/code&gt;, &lt;code&gt;rtk grep&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Git: &lt;code&gt;rtk git status&lt;/code&gt;, &lt;code&gt;rtk git log&lt;/code&gt;, &lt;code&gt;rtk git diff&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;GitHub CLI: &lt;code&gt;rtk gh pr list&lt;/code&gt;, &lt;code&gt;rtk gh pr view&lt;/code&gt;, &lt;code&gt;rtk gh issue list&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Tests: &lt;code&gt;rtk pytest&lt;/code&gt;, &lt;code&gt;rtk go test&lt;/code&gt;, &lt;code&gt;rtk cargo test&lt;/code&gt;, &lt;code&gt;rtk vitest&lt;/code&gt;, &lt;code&gt;rtk playwright test&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Build and lint: &lt;code&gt;rtk lint&lt;/code&gt;, &lt;code&gt;rtk tsc&lt;/code&gt;, &lt;code&gt;rtk next build&lt;/code&gt;, &lt;code&gt;rtk cargo clippy&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Containers and cloud: &lt;code&gt;rtk docker ps&lt;/code&gt;, &lt;code&gt;rtk docker logs&lt;/code&gt;, &lt;code&gt;rtk kubectl pods&lt;/code&gt;, &lt;code&gt;rtk aws sts get-caller-identity&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Data and logs: &lt;code&gt;rtk json&lt;/code&gt;, &lt;code&gt;rtk deps&lt;/code&gt;, &lt;code&gt;rtk env&lt;/code&gt;, &lt;code&gt;rtk log&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This kind of tool is most useful when an agent reads command output frequently. It does not write code for you. It helps the agent read less noise.&lt;/p&gt;
&lt;h2 id=&#34;installation-and-integration&#34;&gt;Installation and Integration
&lt;/h2&gt;&lt;p&gt;The README lists several installation options.&lt;/p&gt;
&lt;p&gt;Homebrew:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;brew install rtk
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Quick install on Linux/macOS:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Cargo:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cargo install --git https://github.com/rtk-ai/rtk
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;After installation, check the version and stats:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rtk --version
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rtk gain
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;To integrate it with AI coding tools, use the init commands:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rtk init -g
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rtk init -g --gemini
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rtk init -g --codex
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rtk init -g --agent cursor
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rtk init --agent windsurf
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rtk init --agent cline
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Restart the corresponding AI tool after initialization. For hook-based agents, Bash commands are rewritten before execution. For example, &lt;code&gt;git status&lt;/code&gt; becomes &lt;code&gt;rtk git status&lt;/code&gt;, and the agent receives compressed output.&lt;/p&gt;
&lt;h2 id=&#34;what-to-watch-out-for&#34;&gt;What To Watch Out For
&lt;/h2&gt;&lt;p&gt;RTK&amp;rsquo;s benefit depends on whether the agent actually reads information through shell commands.&lt;/p&gt;
&lt;p&gt;The README specifically notes that built-in tools such as Claude Code&amp;rsquo;s &lt;code&gt;Read&lt;/code&gt;, &lt;code&gt;Grep&lt;/code&gt;, and &lt;code&gt;Glob&lt;/code&gt; do not pass through the Bash hook, so they are not automatically rewritten by RTK. To make RTK participate, use shell commands such as &lt;code&gt;cat&lt;/code&gt;, &lt;code&gt;head&lt;/code&gt;, &lt;code&gt;tail&lt;/code&gt;, &lt;code&gt;rg&lt;/code&gt;, &lt;code&gt;grep&lt;/code&gt;, and &lt;code&gt;find&lt;/code&gt;, or call &lt;code&gt;rtk read&lt;/code&gt;, &lt;code&gt;rtk grep&lt;/code&gt;, and &lt;code&gt;rtk find&lt;/code&gt; directly.&lt;/p&gt;
&lt;p&gt;That point matters. RTK is not a globally transparent compressor for all agent I/O. It is closer to a proxy at the shell-command layer.&lt;/p&gt;
&lt;p&gt;Windows users should also note that the README recommends placing &lt;code&gt;rtk.exe&lt;/code&gt; in PATH and running it from Command Prompt, PowerShell, or Windows Terminal instead of double-clicking it. It also says WSL is more natural if you want the full hook experience.&lt;/p&gt;
&lt;h2 id=&#34;who-should-use-it&#34;&gt;Who Should Use It
&lt;/h2&gt;&lt;p&gt;RTK is useful for three groups:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Heavy AI coding users&lt;/strong&gt;: people who ask agents to run many &lt;code&gt;git&lt;/code&gt;, &lt;code&gt;rg&lt;/code&gt;, test, and build commands every day.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Large-repository users&lt;/strong&gt;: teams whose command output often reaches hundreds of lines and drowns the agent in irrelevant context.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;People who care about token cost and context windows&lt;/strong&gt;: users who want the model to focus on failures, changes, and key files.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If your project is small, or if your agent mostly reads files through IDE-native tools, RTK may feel less impactful. It shines when command-line output is both long and frequent.&lt;/p&gt;
&lt;h2 id=&#34;my-take&#34;&gt;My Take
&lt;/h2&gt;&lt;p&gt;RTK points in a practical direction. Many AI coding workflows focus on stronger models, larger context windows, and longer tasks, but there is still a plain development problem: agents often read far more than they need.&lt;/p&gt;
&lt;p&gt;Compressing command output before handing it to the model can reduce token usage and lower the chance that noise steers the model in the wrong direction.&lt;/p&gt;
&lt;p&gt;It is not a magic switch, though. To use RTK well, the agent workflow needs to lean on shell commands, and you need to confirm that the hook actually works in your current tool. For Codex, Claude Code, Gemini CLI, Cursor, and Windsurf, RTK is a useful context throttle to test: it does not change the development commands themselves, but it gives the agent cleaner results to read.&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
