Productivity

Spotify routes bulk file reads away from Claude Code and reports 90% fewer tokens

September 5, 2026 at 12:35 AM PT

Spotify Engineering's illustration for the Portal delegation post, a flat graphic marking the split between a frontier model and a cheaper worker model

Image: Spotify Engineering

Why it mattersMost agent token spend is file reading, not reasoning, so the cheapest saving available is routing reads to a smaller model before touching your prompts.

Spotify Engineering published a post on 3 September describing how it cut token use in Claude Code by moving file reading and boilerplate writing to a cheaper model. Dimitri Mazmanov, a principal product manager at Spotify, wrote it. The post reached 184 points on Hacker News.

The starting observation is about where the money goes. Mazmanov writes that most of what a coding agent does "isn't thinking. It's I/O", and gives examples: reading five files to answer a question about one method, generating a test file that matches the twenty test files beside it. Those calls go to a frontier model that he describes as "wildly overqualified" for them.

Two workers and a blocking hook

The setup uses what Spotify calls AiKA Modes inside Portal, its internal platform. A mode is a declarative agent with instructions, a chosen model and attached tools, running on an ephemeral runtime. Two of them do the work. A bulk-reader mode takes several files and a question and returns structured bullets. A code-writer mode takes a spec plus a reference file and produces code that matches the existing patterns, writing it straight to disk so the agent never holds the output in its context.

The interesting part is how the routing is enforced. An earlier version put the rules in CLAUDE.md, which Mazmanov says "sort of worked" because the rules were advisory and the agent could ignore them. The current version is a Claude Code plugin called shunt that registers hooks firing before every tool call. When a read exceeds a line threshold, default 350, the hook blocks it and points the agent at the delegation skill instead. Targeted reads with an offset pass through untouched.

The numbers, and who measured them

Spotify says the mean saving on bulk reads was around 90%, measured across four scenarios against a Java monorepo. That figure is Spotify's own, from Spotify's own harness, so treat it as their result rather than an independent benchmark. The post also cites an expectation that AI coding costs will pass the average developer salary by 2028, and says a quarter of engineering leaders already spend between $200 and $500 per developer per month on tokens, with some past $2,000.

The limits are stated as plainly as the wins, which is the part worth copying. Editing cannot be delegated, because the worker's summaries lack reliable line numbers. Reasoning cannot either: the worker found surface patterns but missed a thread-safety bug that the frontier model caught once given the right context. Each delegation is a network round trip taking 10 to 30 seconds, and Portal caps a single invocation at 30 seconds, so the line threshold exists because delegation costs more than it saves on small files.

Portal itself is internal to Spotify, so nobody outside can run this as described. The shunt plugin is published at spotify/portal-ai-plugins, which is Apache-2.0 and was created on 23 July, but it calls the Portal CLI and needs a Portal instance behind it. The transferable part is the shape: a pre-tool-use hook that refuses an expensive call and names a cheaper path, rather than instructions in a prompt file that the agent may or may not follow. Any team measuring its own agent spend can check the same split first, how much of it is reading versus reasoning, before rewriting anything.

Source

Portal by Spotify cut my Claude Code token usage by 90%, Spotify Engineering

Source: Spotify Engineering

This item was written by an AI system from the linked source. Reveneau is responsible for what it publishes.

More from AI News

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

Spotify published how one engineer stopped Claude Code from reading large files directly, routing them to Gemini 2.5 Flash instead, and measured a mean saving of about 90% on bulk reads across a Java monorepo.

Productivity

Spotify published a Claude Code plugin that hands file reading to a cheaper model, and measured a 90% cut in bulk-read tokens

Spotify published a Claude Code plugin called shunt that sends file reading and boilerplate writing to Gemini 2.5 Flash workers, and reports mean savings of about 90% on bulk reads against a Java monorepo.

Productivity

Spotify's Claude Code plugin blocks big file reads and sends them to a cheap model instead

Spotify published a Claude Code plugin that intercepts reads of files over 350 lines and routes them to a cheaper worker model, reporting mean savings of around 90 percent on bulk reads in its own tests.

Productivity