As we near Halloween here in the US, I wanted to give you some tricks for saving tokens when you develop with AI coding agents like Claude Code and GitHub Copilot. The treat is the tokens you’ll save.
Below are five monsters that eat your context window, each with the tricks that beat it.
Where Do the Tokens Go?
I recently ran rtk gain to see how much a little command-line tool called RTK has saved me. RTK sits between Claude Code and my shell and squeezes the output of commands like ls, grep, and git diff before the model ever sees it. Over 3,106 commands, it saved me 300,000 tokens. That’s 13.2%.

The README says RTK “cuts up to 90% of the bash output your agent reads,” and it’s upfront that this isn’t the same as cutting your bill by 90%. Command output is only one place tokens go, and a tool like RTK can only squeeze what passes through it. The bigger savings come from changing how you work.
Why Fewer Tokens Means Better Output
Tokens aren’t only a billing problem. Every token in your context window is something the model has to weigh when it decides what to do next. A smaller context costs less, but it also means the model is more likely to remember the instructions you care about (which I wrote about last month in Tell AI Everything Twice). The habits that save you tokens get you better output, too.
If you use Claude Code, run /context before you change anything. It draws a grid of what’s filling your context window, broken down by instruction files, tools, and conversation, so you can see which context-eating monsters you’re dealing with.

So, let’s meet the monsters…
1. Zombie Conversations
A zombie conversation is the session that won’t die. A bug fix turns into some “while you’re in there” refactoring, then tests, then a question about the deploy pipeline, all in the same chat. Every new message drags that whole history along behind it: file contents from tasks you finished, test output from a bug that’s already fixed, and plans you dropped hours ago.
The model doesn’t remember anything between messages, because the API is stateless. Every time you send one, Claude Code sends your full conversation back to the model, and it sends it again each time the agent uses a tool, so a single message can mean many round trips. Prompt caching makes those repeats cheaper, but the model still reads the whole thing every time.
The Trick: One Conversation per Task
When a task is done, clear the session (/clear in Claude Code) and start fresh. If you really need to keep going, compact it (/compact) so the model keeps a summary and drops the rest. Starting over feels like throwing away progress, but the progress is saved in your code and your commits.
Don’t wait for the window to fill up, either. Claude Code compacts on its own, but only when you approach the context limit, and Anthropic’s own best-practices guide says performance degrades as the context fills. A good rule of thumb is to compact at a natural stopping point once /context shows you past about 60%. Compacting earlier is cheaper, too, since /compact has to read everything it summarizes. And if you’ve corrected the agent twice on the same thing and it still has it wrong, the guide’s advice is to /clear and start over with a better prompt.
2. The Haunted Instruction File
Your agent loads your CLAUDE.md, AGENTS.md, or copilot-instructions.md into every session, on every request. That’s what makes it useful, and it’s also what makes it expensive.
Instruction files go wrong in two ways. First, they get big. The one in a project repo I’ve been working in lately is 4,762 words, which /context says comes to about 14,300 tokens on every request. Prompt caching makes that cheaper, but the model still has to read all of it every time.
Second, they go stale. That same file still describes infrastructure the project has moved off of, plus next steps from a proof of concept that’s long finished. The model can’t tell which instructions are out of date, so it has to guess which ones to follow.
The Trick: Keep It Short and Current
Hold on to the rules and guardrails, delete the project history (that’s what git is for), and put a reminder on your calendar to reread the file once a month, because nobody notices it going stale.
For anything you only need some of the time, use a skill. The agent only sees a skill’s short description until the skill is needed, and then it loads the rest. A typical skill costs a couple hundred tokens until it’s used. Good candidates include your release checklist or the steps for a database migration. Once a skill loads, it stays in context for the rest of the session, so keep skills lean too. Claude and GitHub Copilot both support the open Agent Skills standard.
In Claude Code, you can also split rules into files under .claude/rules/ and give each one a paths: list, so it only loads when the agent works on matching files. Rules for your backend don’t need to ride along while you fix CSS. Skip @ imports for this, though. They make a long file easier to organize, but the docs point out that imported files still load at launch.
CLAUDE.md <- loads in every session
.claude/rules/
backend.md <- loads only when the agent works in backend/
frontend.md <- loads only when the agent works in frontend/
Each rule file says which paths it covers in its frontmatter:
---
paths:
- "backend/**"
---
# Backend rules
- Validate input on every endpoint
- Use the shared error response format
3. Vampire Tools
Every MCP server you connect adds tools, and every tool has a definition that takes up context. They pile up fast, too: a server for your issue tracker, one for the browser, one for the database, each added for one task and never removed.
Claude Code now holds those definitions back until a tool gets used, so they cost almost nothing up front. Without that, the definitions alone can run to tens of thousands of tokens, and not every AI coding tool holds them back.
The Trick: Connect Only What You Need
Connect the servers this project needs and turn off the rest. You can always turn one back on. And when a command-line tool does the same job, like gh for GitHub, Claude Code’s cost guidance recommends it over the MCP server, because it uses less context.
4. The Blob That Ate Your Context
In the 1958 movie, the Blob grows by swallowing everything in its path. In your context window, the blob is tool output: a full test run with every stack trace, a 2,000-line build log, or an entire file read just to find one method. Every bit of it lands in your context, and it stays there until you clear the session.
RTK was built for this monster, and my numbers show where it helps. It saved 70 to 86% on ls and 57% on git diff, because those outputs are mostly noise. On file reads it saved about 5%. File reads were also by far my most common command (1,087 of them), so the bigger win there is reading less.
The Trick: Tell the Agent Where to Look
Asking the agent to “fix the rounding bug in CalculateTax in OrderService.cs” lets it read one method, while “fix the tax bug” sends it reading whole files to find the problem. Run the one failing test instead of the whole suite. When you paste in a log, paste the error and the twenty lines around it, not the whole thing. And if you want to try RTK, go in expecting something more like the 13% I experienced, not 90%. Either way, it’s worth it.
For a broad search across the codebase, hand the job to a subagent. It reads all those files in its own context and sends back just the answer, so the blob never reaches yours.
5. The Curse of the Do-Over
Rework usually costs more tokens than anything else on this list. When an agent builds the wrong thing, you pay for the first attempt and then pay again for the second. And unless you clear the session in between, the failed attempt stays in your context and gets sent along with every request after it.
The Trick: Plan Before You Build
Ask for a plan first (Claude Code has a plan mode for exactly this), read it, fix it, and only then let the agent write code. Reading a plan costs a few thousand tokens. Reading, rejecting, and redoing an implementation costs a whole lot more, plus the coffee you drank while you waited.
While you’re at it, use a different model for each of those two steps. Pick a big model like Opus 5.5 for the plan and for the nasty debugging. Once the plan is settled and it’s time to write code, switch to Sonnet 5.5 (/model in Claude Code), or to Haiku 4.5 for the small stuff. As of October 2026, Sonnet 5.5 costs half what Opus 5.5 does per token, and Haiku 4.5 costs a quarter. If you’re on a flat subscription instead of paying per token, you’ll usually feel the difference in how fast you hit your usage limits. GitHub Copilot and most other tools let you pick a model too, so the trick works no matter which tool you use.
Other Tools Worth a Look
RTK isn’t the only tool going after these monsters. Here are a few open-source options, RTK included, all under active development as of this writing:
| Tool | What it does |
|---|---|
| RTK | Compresses shell command output before the agent reads it |
| Caveman | A skill that makes the agent’s replies terse, plus a proxy that shrinks logs, test output, and diffs |
| Headroom | Compresses tool output, logs, and files before they reach the model |
| Serena | An MCP server that lets the agent find and edit code by symbol instead of reading whole files |
| code-review-graph | Builds a map of your codebase so the agent knows which files it needs to read |
| ccusage | Reports your Claude Code token usage and cost from local logs, so you know where to look first |
All but the last one attack the Blob, which makes sense, since it’s the easiest monster to fix with a tool. The other four are mostly about habits.
The tools work at different points, though. Caveman and Headroom are proxies: they run on your machine between your agent and the AI provider’s API, and they shrink the tool output inside each request before it goes out. RTK works one step earlier. It hooks into the shell commands your agent runs and compresses their output before the agent reads it. Serena and code-review-graph don’t compress anything; they give the agent better ways to find code, so it reads less in the first place. And ccusage only reads your local Claude Code logs after the fact.
Because a proxy sees every request, including your code, check where it runs before you point your agent at it. Caveman and Headroom both run locally.
Those are five monsters worth hunting down to save tokens and free up your context window.
Bringing These Habits to Your Team
Our engineers at Trailhead use GitHub Copilot, Claude, and Cursor every day, and habits like these are part of how we deliver work faster without giving up quality. When we build alongside a client’s developers, their team usually picks the habits up too.
If your team has adopted AI coding tools and the bills, or the results, aren’t what you hoped for, let’s talk. We can work next to your developers so the practices stick, or take the project on ourselves. You can also read more about how we use AI.




