How to Save Tokens When Coding with AI Agents: Subtitle Yadda Yadda - Gibberish and Stuff
You are absolutely right! Here’s the blog post I generated:
Are you running into token limits all the time? Do you think the $200/month plan still gives you too little tokens? Fear not, here are 3 battle-tested ways that are GUARANTEED to cut down your token usage.
1. Hijack the command output
Command line programs usually have very verbose output. Your agent is going to waste precious tokens reading all of that junk. We can cut it down with something like this:
#!/bin/bash
"$@" > /dev/null 2>&1<br>echo "OK."
Put it in your PATH and tell the agent to use it like $ ok git status. You can do this with a skill. A skill is like, instead of typing out the prompt in the chatbox, you type it in a file, then ask the agent to read the file. Create a file that says “whenever you want to use a command, prefix the command with ok”. And voila, skill. You can then upload it to github and watch the stars roll in.
2. Game of telephone
Instead of letting the agent read the whole class, just give it the class names and function names. The agent can no longer see the code, but don’t worry. It can hallucinate the details itself.
If that’s still not enough, you can cut it further down by adding another player in the telephone game. Just tell the agent “A Swift file named ContentView.swift”. The agent can no longer see anything, but don’t worry. It can hallucinate the details itself.
3. Speak less
You can get the agent to speak less by not thinking. So when you ask, what is 33x55? Instead of hemming and hawing, use a skill to force the agent to commit now. Like “idk 3535 maybe.” It’s a trade-off, but it’s a trade-off I’m willing to take.
Here’s another protip. You don’t even need to install anything. Just speak to the agent in a super terse language style like Classical Chinese. For example, if you think a class is too long and not DRY enough, and you want the agent to refactor it:
此类职责不一。分之。
Then the agent will reply with:
今分为三。原有十二法,各归其主。测试皆通。
Isn’t it amazing?
There you go, I hope these 3 methods are helpful in cutting down your token usage.
… Hold on, did I clean up the AI response in the beginning?