DEV Community

Cover image for How to Save Tokens Using rtk—Part 2
Ganesh Kumar
Ganesh Kumar

Posted on

How to Save Tokens Using rtk—Part 2

In Part 1, I looked at codebase-memory-mcp and how it can reduce tokens by helping an AI agent find the right code instead of reading unnecessary files.

This time, I tested another tool:

rtk (Rust Token Killer)

Its approach is different.

Instead of helping the agent find code, rtk compresses the output of shell commands before it reaches the AI agent.

What is rtk?

Normally, an AI coding agent runs commands like:

git status
git diff
grep
ls
ps aux
Enter fullscreen mode Exit fullscreen mode

and the full output gets added to the context.

rtk sits in between and reduces that output.

So instead of:

git status
Enter fullscreen mode Exit fullscreen mode

I can use:

rtk git status
Enter fullscreen mode Exit fullscreen mode

The goal is simple: Send the same useful information using fewer tokens.

What did I measure?

Across 442 commands, the reported numbers were:

Metric Result
Input tokens 628.8K
Output tokens 326.3K
Tokens saved 302.8K
Overall reduction 48.1%

That's a significant reduction, but the interesting part is how much the savings vary by command.

Some commands benefit a lot

For example:

Command Token reduction
ps aux 98%
Large git diff 90%
git status 53%
grep 22.6%

Some commands produce huge amounts of repetitive output, so rtk can remove a lot of unnecessary information.

I also tested it on my actual task

grep -C 2 "ProcessReview" .
Enter fullscreen mode Exit fullscreen mode

The raw output was around:

6,065 bytes

With rtk:

2,972 bytes

That's roughly a 51% reduction

And the important part is that the useful information was still there.

rtk wasn't trying to understand my code.

It was simply removing output that the AI didn't need.

Conclusion

rtk can make the surrounding shell interactions cheaper.
That means we don't only try to compress the context an AI reads. First, try to stop it from reading unnecessary context. Then compress whatever remains.

With rtk, I saw roughly 48% savings across terminal interactions.

Thanks for reading!

If you are interested, you can check out my tool, MakeSense, which turns public GitHub pull requests into concise summaries, prioritized insights, and interactive quizzes.

It's free, unlimited, and source-available.

If you review open-source code, I'd love for you to give it a try and share your feedback.

MakeSense: makesensegithub.com

Top comments (0)