A Spotify engineer cut Claude Code token use about 90% by blocking large file reads and sending them to a cheaper model

Image: Spotify Engineering
Why it mattersMost agent spending goes on reading and generating files rather than reasoning, so the cheapest cost control is blocking the expensive model from doing work it is overqualified for.
Spotify Engineering published a post on 3 September describing how one of its engineers cut token spending in Claude Code by stopping the model from reading large files at all. The agent is forced to hand them to a cheaper model and receive a summary back. Across four scenarios tested on a Java monorepo, the post reports mean savings on bulk reads of around 90%.
The argument behind it is that most of what a coding agent does is input and output rather than thinking: reading five files to answer a question about one method, or generating a test file that copies the pattern of the twenty beside it.
How the block works
The mechanism is a Claude Code plugin called shunt, which registers hooks that fire before a tool call runs. One hook watches every file read. When a file is longer than a configurable threshold, 350 lines by default, the hook refuses the read and points the model at a delegation skill instead. A second hook catches the same thing arriving through shell commands such as cat and head. Targeted reads with an offset and a limit pass through, because the agent already knows which section it wants.
The work then goes to what Spotify calls a mode: a declarative agent defined by a name, instructions, a model and some parameters, running on an ephemeral runtime. Two modes carry the routing. One reads files and answers a question about them. The other generates predictable code, such as tests or config stubs, against a required reference file so the output matches existing patterns. Both use Gemini 2.5 Flash in the examples, and the post says the model field accepts any model configured in the Portal instance.
The generated code goes straight to disk and the expensive model never sees it, which is where the saving on the writing path comes from. The post says this second path is harder to measure in tokens, and gives no percentage for it.
What the author says does not work
Three limits are stated in the post. Editing cannot be delegated, because the worker model's summaries carry no reliable line numbers, so the agent still has to read the exact section it intends to change. Reasoning cannot be delegated either: in the author's testing the worker model found surface patterns but missed a thread-safety bug that Claude caught quickly once given the right context. The routing therefore excludes debugging, architectural decisions and safety-critical code by design.
The third limit is latency. Each delegation is a network round trip, replies typically take 10 to 30 seconds, and Portal cuts off a single invocation at 30 seconds, so large generations have to be split. Below the line threshold the delay costs more than the saving.
The 90% figure is Spotify's own measurement of its own tooling on its own repository, with no independent verification. The plugin also requires a Portal instance, a Spotify product sold as a seat licence plus token use. The plugins are published under Apache-2.0 at spotify/portal-ai-plugins.
The transferable part needs none of that. A hook that refuses an expensive operation is enforcement, where a rule written into a config file is advice the model may ignore. The post says the first version was exactly that, routing rules in a CLAUDE.md file, and that it worked only sometimes because nothing made it binding. Any team paying per token can apply that distinction today, whatever it routes the work to.
Source
Portal by Spotify cut my Claude Code token usage by 90%, Spotify Engineering, 3 September 2026. The post carries 103 points on Hacker News.
Source: Spotify Engineering
This item was written by an AI system from the linked source. Reveneau is responsible for what it publishes.
Get AI News in your inbox
New developer tools, model and agent releases, and how teams are actually shipping with them. Short, and only when there is something worth reading.
