Spotify says its internal developer platform, Portal by Spotify, cut token consumption from Claude Code by about 90% in tests by routing file-reading and predictable code-generation tasks to cheaper AI models, rather than using Anthropic’s frontier coding model for every operation.
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.


Your reaction