Article complete

Spotify Cuts Claude Code Token Usage by 90%

Spotify’s Portal for Backstage routes routine coding-agent tasks to cheaper models, reducing the amount of frontier-model tokens Claude Code consumes.

A stylized illustration of a man with headphones, colorful sound waves, and code in the background, featuring the Spotify log

Key takeaways

  • Spotify's Portal significantly reduces Claude Code token usage by rerouting tasks to more cost-effective AI models.
  • The internal platform employs 'AiKA Modes' for flexible task management without the need for separate infrastructure.
  • Engineers tested the approach on a Java monorepo, successfully managing file reading and code generation efficiently.
  • The Shunt plugin ensures large file reads are redirected to a bulk-reader mode, minimising token consumption.
  • The system allows for direct code generation and writing, optimising operations while reserving Claude for complex reasoning tasks.

Takeaways drafted with AI from the article text.

Watch the video· 5:03

Subscribe to AIM Network
EXPOSED: Spotify Cut Its Claude AI Bill by 90 Percent and Did Not Even Switch ModelsWatch on AIM Network

The approach uses Portal’s “AiKA Modes”, which are declarative agents that run on ephemeral runtimes. Developers can specify the model, instructions, parameters and MCP tools for each mode without managing separate infrastructure or API keys.

Spotify engineer Dimitri Mazmanov tested the approach on a Java monorepo using two modes: a bulk-reader for reading multiple files and a code-writer for predictable code-generation tasks. Both examples use Google’s Gemini 2.5 Flash as the worker model, although Portal can be configured with other models.

“Most of what an AI coding agent does for me isn't thinking. It's I/O,” Mazmanov wrote. The setup keeps those token-heavy operations away from Claude Code while retaining Claude for tasks that require more reasoning.

The routing is enforced through a Claude Code plugin called Shunt. It uses PreToolUse hooks to intercept large file reads and redirect Claude to the bulk-reader mode. By default, reads of files exceeding 350 lines are blocked, while targeted reads using offsets and limits continue to pass through.

A second mode handles output-heavy tasks such as generating tests, configuration scaffolding and type stubs. It receives a specification and reference file, generates the code and can write it directly to disk, meaning Claude does not need to consume the generated output in its own context.

Spotify said the test measured Claude's token consumption across four scenarios in a Java monorepo, with mean savings from bulk reading of around 90%. The code-generation case was harder to measure because the unoptimised workflow includes both reading reference files and generating code as Claude output.

The approach has limits, and Spotify said the worker models are not intended to handle debugging, architectural decisions or safety-critical reasoning. 

Besides, delegated analysis also does not reliably provide the line-level information Claude needs for editing. Network latency is another constraint, with typical delegation taking 10–30 seconds and Portal imposing a 30-second limit per invocation.

Mazmanov described the broader approach as “model routing powered by AiKA modes”, allowing teams to change the worker model or instructions without modifying the routing plugin itself.

Spotify made the bulk-reader and code-writer modes publicly available through AiKA, allowing developers to reuse or customise them across projects. 

Published

Spotted an error? Tell our editors. Read our editorial standards and corrections.

Selling to AI teams? Put your brand in front of the 5M+ people who read AIM every month. Plan a campaign

About the author

Principal Correspondent

All stories
Belamy · Daily

The day’s AI news, before your first meeting.