AI News · Tools

Saving Tokens in Claude Code:
What actually helps.

DE Auf Deutsch lesen

August 28, 2026 · approx. 14 min read

When coding with an agent, token costs pile up in several places: in the code it generates, in finding the right file, and in long tool output. I tested Ponytail, Graphify and RTK on the same project. All three help, but not in the same way and not for every task.

A coding agent works with whatever sits in its context window: project instructions, files it has read, tool output, and conversation history. The more of that gets processed for a given request, the higher the input costs usually are. Prompt caching and automatic compaction change the arithmetic, but they don't remove it.

That's why the three tools in this post intervene at different points. Ponytail is meant to prevent unnecessary code. Graphify is meant to shorten the search through the repository. RTK reduces development-tool output before it reaches the agent.

Transparency note: The measurements come from one project: PlantWiz, a production Vue 3 application with a Node backend, roughly 45,000 lines of TypeScript and Vue, and 327 unit tests. For Ponytail the task was a CSV export of the plant list; for Graphify it was extending user and garden management in the admin area. These are case studies, not a general-purpose benchmark. Vendor figures are marked as such.

The three approaches compared

Illustration of a coding workflow with editor, dependency graph and condensed terminal output.
Ponytail targets the code that gets generated, Graphify targets orientation within the project, and RTK targets tool output.
ToolTargetsSavesEffortMeasured
PonytailHow much code the agent writesOutput tokensInstall a skill−43 % (net)
GraphifyHow the agent finds codeInput tokens spent searchingBuild and maintain an index−96 % (targeted)
RTKHow much tool output comes backInput tokens from tool callsOne-time hook setup−89 % (47 cmds)

The tools can be combined, since they affect different parts of the workflow.

Ponytail: getting the agent to write less code

Recommended

The "lazy senior developer" as a skill

Ponytail on GitHub · a skill for Claude Code, Codex, Cursor, Gemini CLI and others

Ponytail is a skill file with a short checklist. Before writing anything, the agent is meant to check whether the function already exists, can be solved with a standard function, or is even needed at all. As soon as a simple solution suffices, the search stops.

The result is fewer output tokens and less code that later needs maintaining. Unnecessary code usually costs more over its lifetime than it did to write.

And this is where it gets interesting. An independent test shows a very mixed picture:

Another test on a FastAPI/React project found 54% less code with 22% fewer tokens and 20% lower costs. That matches my own result: Ponytail helps mainly on tasks where an agent would otherwise over-build. On a precise ticket, the extra checklist is more overhead than benefit.

Measured again: the ladder on a real task

The task on PlantWiz was: "CSV export of the plant list." A typically terse ticket. I picked it deliberately so the ladder would get nothing handed to it: the project had no CSV code at all, no suitable library, nothing to reuse. Ponytail could only trim here, not cut away. I implemented the task twice, once straightforwardly, once with the ladder.

ResultWithout PonytailWith PonytailDifference
New files61−5
Lines of code569104−81.7 %
Characters18,0593,539−80.4 %
Output tokens (≈)4,515885−80.4 %

The version without the ladder built what a thorough developer typically builds: a type file with an options object, an RFC-4180 serializer, a column definition with ten selectable fields, a composable with localStorage persistence, a modal with column selection, delimiter and date options with a live preview, plus 103 lines of tests. None of it is wrong. None of it was requested either.

The version with the ladder landed on rung 4 (native platform feature?): a Blob and an anchor element. No library. What remained was 44 lines in a composable, a button next to the existing PDF export, and one test for the one genuinely tricky part: quoting semicolons and quotation marks. The formula-injection hardening against CSV injection stayed in, because Ponytail explicitly exempts security measures from trimming.

Net result: The skill itself costs around 1,700 tokens, loaded on every coding task. Gross savings were 3,630 output tokens. Net, that leaves roughly 43% savings. That's in the same range as the 22% from the vendor test, and well below what the gross figure of −80% suggests.
Honest summary: One run, performed by me, aware of both variants — not a blind test. The size difference also depends on how generously you build the comparison variant; I wrote it the way I actually encounter it in projects, but that remains a judgment call. I trust the direction, not the second decimal place.

The cost: the ladder costs something even when it finds nothing

This is Ponytail's downside: The 1,700 tokens are incurred on every coding task, even the one where there's nothing to simplify. On a tightly scoped ticket ("add field X to endpoint Y"), the ladder is pure overhead, and that's exactly what the independent counter-test above measures when it finds 6K instead of 2.3K tokens on the auth task.

There's a second point that's hard to put a number on: the trimmed version is poorer. No delimiter switch, no column selection. If someone asks for a comma export the day after tomorrow, it gets rebuilt. That rebuild costs tokens again. Ponytail is betting that the question usually won't come. That bet is usually right, but it's a bet, not a saving.

For openly worded tasks, roughly 40% net is realistic; for precise tickets the effect can be zero or slightly negative. The 465 lines not written also never need to be maintained, read, or migrated later.

A side finding worth more than the measurement: Before the CSV test, I had run Ponytail on the task "extend user and garden management in the admin area." Rung 2 of the ladder, does this already exist?, revealed that PlantWiz already had GET/PUT /admin/user-plans and a complete 93-line user tab in AdminView.vue. Half the task was already done, nobody just remembered. The version without the ladder built it a second time without comment. As a data point it's worthless. It's an outlier on the high side, but a useful argument for the ladder.

Graphify: searching code as a graph

Recommended

A knowledge graph instead of grep

Graphify on GitHub · graphify.net

Graphify parses a project locally with tree-sitter (around 40 languages) and builds a queryable knowledge graph from it: files, symbols, dependencies and the relationships between them. Instead of searching through files, the agent can query the graph: what depends on this function? What path leads from A to B?

Technically it's cleanly solved: the graph lands as graph.json in the project, no vector database needed. Every edge carries metadata on whether it was found directly in the source (EXTRACTED) or inferred from dependencies (INFERRED). That honesty about its own certainty is rare and welcome.

Two limitations worth knowing about:

Measured again: orientation in the admin area

Building the index on PlantWiz took 38 seconds for 258 code files and produced 2,014 nodes, 2,994 edges and 179 clusters. The graph.json is 1.7 MB. The agent never reads it in one piece; it queries it.

Same task, same question: which files do I need to touch, and how are they connected? Once done classically with search and read, once via the graph:

ApproachCallsContext
Classic: grep + read filesgrep -rln · admin.ts · AdminView.vue63,241 B
Graphify: targeted queryexplain admin.ts · explain AdminView.vue2,552 B
Savings−96.0 %

The reason for the gap is mundane: AdminView.vue has 1,323 lines and 51 KB. Anyone who wants to know what's in it normally reads all of it. graphify explain delivers, for 1,948 bytes, the list of all 58 symbols it contains with line numbers. That's enough to decide which 40 lines you actually need.

The cost: two gaps worth knowing about

Free-text search is the weakest part. graphify query "admin area user management" returned 6,498 bytes, including plantPairs.ts, a file about plant neighborhoods where the words admin, user and garden appear not once. The hit came from fuzzy name matching. If you already know the symbol name, explain gives excellent answers. If you're searching for it, you get noise — exactly when you'd need the graph most.
The graph ends at the HTTP boundary. graphify path "AdminView.vue" "gardens.ts" responds: No path found. Yet the component demonstrably calls the admin API, just via fetch() over HTTP. No static analysis sees that edge. In a full-stack project you therefore end up with two disconnected graphs instead of one: frontend and backend. For the common question "which backend does this form talk to?", the graph doesn't help.

Two smaller issues from the log: 27 .sql files contributed nothing because tree_sitter_sql isn't bundled. On PlantWiz, with a 4 MB init.sql, that's half the data model. And 11 more files produced exactly zero nodes.

Graphify pays off once a project moves beyond a prototype, but with realistic expectations. It explains a known file excellently and helps less with finding that file in the first place. In my measurement, searching by filename first and then calling explain was the cheapest path. Anchor the index rebuild in a pre-commit hook or CI so the graph stays current.

RTK: condensing tool output

Recommended

Rust Token Killer

RTK on GitHub

RTK is the least spectacular of the three and, in my view, the most convincing. It's a CLI proxy that condenses the output of common developer commands before it reaches the agent: repetitions get collapsed, files and errors get grouped, long output gets trimmed.

It happens transparently via a PreToolUse hook: git status is automatically rewritten to rtk git status. You don't notice it day to day. Over 100 commands are covered: Git, test runners, build tools, package managers, Docker, Kubernetes. The vendor claims 60-90% savings, up to −90% for cargo test.

Illustration of long terminal output funneled down into a short condensed diagnosis.
RTK removes repetition and formatting noise. During debugging, exactly one omitted detail can turn out to matter.
Watch out for a name collision: There's a second project also called rtk (Rust Type Kit). If rtk gain doesn't work after installing, you have the wrong binary. Check with rtk --version.

Why RTK pays off fastest: it's the only one of the three measures that requires no behavior change and leaves no artifact to maintain. Set it up once, then it works in the background. And it targets exactly where the most context gets burned in practice: test output and build logs.

Measured again: 47 commands in daily use

Vendor figures are vendor figures. So I cross-checked RTK 0.43 against a production project: PlantWiz, a Vue 3 application with a Node backend, around 45,000 lines of TypeScript and Vue, 327 unit tests. Each command run once raw and once through RTK, measured in bytes of output:

CommandRawWith RTKSavings
vitest run (327 tests)7,719 B20 B−99.7 %
git diff HEAD~3 HEAD467,163 B44,026 B−90.6 %
ls frontend/src888 B166 B−81.3 %
git status705 B282 B−60.0 %
find *.vue1,265 B556 B−56.0 %
deps (package.json)1,073 B482 B−55.1 %
git log --oneline -301,272 B1,272 B±0 %
grep -rn "fetch("1,175 B1,175 B±0 %

Across every command run in the project, rtk gain reports, after 47 calls, an estimated 149,000 tokens saved out of 167,300 raw tokens, or 89.1%. RTK derives the token figure from output bytes. For this project the value therefore sits at the upper end of the vendor's stated 60-to-90% range.

Three observations. First: the gain is extremely unevenly distributed. A single git diff accounted for 106,000 of the 149,000 tokens saved. Second: for commands that are already compact, such as git log --oneline or a grep with few hits, nothing happens — RTK passes them through unchanged. No harm, but no benefit either. Third: the effect is largest exactly on the output you'd read completely least often anyway. Test runners and build logs are 95% formatting.

The cost: information gets lost

RTK's real downside: it doesn't show up in the marketing numbers: compression means omission. What gets left out is decided by a filter, not the agent. Sometimes it's exactly the detail that would have explained the bug.

Three places where I noticed this concretely during measurement:

The workaround is simple, you just have to know it: RTK is right for the normal case and wrong for debugging. If a test is red and the agent is going in circles, the raw output belongs there. rtk proxy <command> bypasses the filter. Skip that and you risk the worst of all outcomes: an agent guessing off a summary, burning more tokens than the filter ever saved.


What to check before installing anything

These habits cost no extra tool and often cut more context than a new hook.

1. Clear the context deliberately

A long session also contains earlier attempts, files that were read, and tool output. That can raise the cost of every further request and make orientation harder. For independent tasks, a fresh context via /clear is worth it; for an ongoing task, /compact can be the better choice.

Illustration of a filling context window with several layers of information and a marker for a restart.
Project knowledge, tool output and conversation history share the same context window. A new task with a fresh context keeps costs easier to follow.

2. Load MCP servers deliberately

Check with /context which MCP tools actually take up context. With Tool Search enabled, Claude Code loads only tool names by default and fetches full definitions only when needed. Servers with alwaysLoad, disabled Tool Search, or verbose descriptions can still take up noticeable space. Disabling servers you don't need remains sensible, but it's not a blanket token-saving trick.

3. Delegate searches

When a question touches many files, a subagent can take over the research. It works in its own context window and returns only the result. That saves context in the main thread, but costs an extra agent call. For a simple search that's often too much; for an extensive survey it can pay off.

4. Pick the right model

Not every task needs the strongest model. Renamings, formatting, simple text changes get handled by a smaller model at a fraction of the cost. The trick is making the switch a habit.

5. Plan first, then build

Plan mode looks like a detour, but it's often the shorter route. An agent that heads off in the wrong direction and has to be walked back costs a multiple of the tokens an alignment step would have cost upfront.

6. Keep project instructions short

Global instructions get loaded at the start of every session. Keep them short enough to be useful on every task. Detailed procedures belong in files the agent reads only when needed. Check with /context what actually got loaded in your setup. The official context view shows what content gets added at which stage.


A sensible order

The tools complement each other. I'd check them in this order:

  1. Check your own context. Use /context, close out independent tasks with /clear, and clean up global instructions.
  2. Set up RTK. The setup is small and the benefit shows up on large test and build outputs. Know about rtk proxy for debugging.
  3. Test Ponytail on open-ended tasks. In my measurement, 43 percent net savings remained after the skill's own cost. On precisely described tickets, the math can also come out negative.
  4. Introduce Graphify only with a maintenance plan. For known files, the query was very economical. The index has to stay current and doesn't reliably capture HTTP connections.

The biggest savings in my measurements came from individual cases. For RTK it was a single git diff accounting for 106,000 of the 149,000 estimated tokens saved. For Graphify it was a 51 KB file that would otherwise have been read in full. For Ponytail it was an options modal that the ticket never asked for. Expect savings to be lumpy rather than even.

Calculate net for every tool. In this case Ponytail brought 80 percent less output gross; after the roughly 1,700 tokens for the skill, 43 percent remains. A Graphify query also costs context when it misses the target. RTK reduces tool output; its token figures are an estimate derived from bytes, not a bill from the model provider.

Measure before and after a change, on the tasks your team actually works on. Note the model, tool version, task, and the metric used. Then you can tell whether a tool cuts costs or just redistributes them.

Token costs under control?

I set up Claude Code in development teams, including hooks, skills, and the question of which tasks belong with an agent in the first place. 30-minute intro call, free of charge.