3 min Devops

Spotify reduces Claude Code token usage by 90 percent

Spotify reduces Claude Code token usage by 90 percent

Spotify has developed a method to drastically reduce Claude Code’s token consumption. Through its internal developer platform, Portal, routine tasks such as reading files and predictable code generation are routed to less expensive AI models. In tests, this resulted in an average 90 percent reduction in Claude’s token consumption.

The system runs on what Spotify calls AiKA Modes, agents that operate on temporary runtimes. Developers specify per mode which model, instructions, and MCP tools to use, without having to manage separate infrastructure or API keys.

Spotify engineer Dimitri Mazmanov tested the approach on a Java monorepo. He configured two modes: a bulk reader for reading multiple files and a code writer for predictable code snippets. Both modes use Google Gemini 2.5 Flash as the worker model, though Portal also supports other models.

Mazmanov states that the agent generally does not need to think but functions as I/O. This is still a costly operation if it has to be performed by an AI model. These I/O operations are therefore kept away from the expensive Claude, so that the frontier model remains available for tasks that actually require reasoning.

Shunt routes the traffic

Routing is handled via a Claude Code plugin called Shunt. Using PreToolUse hooks, Shunt intercepts large file reads and redirects them to bulk-reader mode. By default, reads of more than 350 lines are blocked. Targeted reads with offsets and limits are allowed to pass.

Code-writer mode receives a specification and a reference file, generates the code, and writes it directly to disk. As a result, Claude does not need to load the generated output into its own context.

Clear limits

Spotify emphasizes that the worker models are not suitable for debugging, architectural decisions, or mission-critical reasoning. Delegated analysis also does not always provide the line-accurate information that Claude needs when editing code. In addition, delegation typically takes 10 to 30 seconds, while Portal enforces a hard limit of 30 seconds per call.

The bulk-reader and code-writer modes have been made publicly available via AiKA, allowing developers to reuse or customize them for their own projects.

Model routing is complex

What is described here is a form of model routing that can be implemented in various ways. AI providers also offer routing themselves, though this depends on the context. For example, chat windows often include an “Auto” option, where the complexity of a prompt determines whether an expensive LLM is actually necessary.

Nevertheless, model routing is by no means always effective. Those given the choice to use certain models, and who face no further restrictions, will logically opt for the best available model. For organizations that want to give their staff control but also avoid burning through an unnecessary number of tokens, this presents a dilemma. Currently, the obvious approach is to make the most expensive LLMs available only for the most complex roles, but even this is still experimental. AI models in the workplace are too new a phenomenon to rely on established best practices regarding model routing. Spotify’s example is, above all, pragmatic, demonstrating a clear understanding of unnecessary costs. There’s already much to be gained here for less well-informed organizations.