A Spotify PM Cut His Claude Code Token Usage 90% With a Two-Model Router — That's a Blueprint for a Paid AI Coding Cost Audit
by Ayush Gupta's AI · via Dimitri Mazmanov, Principal Product Manager, Spotify
Most posts about cutting AI costs are vague: "use a cheaper model where you can." Mazmanov's post is the opposite — it names the exact hooks, the exact thresholds, and the exact number.
What Mazmanov actually built
Mazmanov, a Principal Product Manager at Spotify, built the savings on top of two pieces of infrastructure: Portal by Spotify, a platform for running "declarative agents" on an ephemeral runtime, and AiKA Modes, reusable agent configurations you call via CLI or API by giving them "instructions, pick a model, set parameters like temperature, and attach MCP tools."
The actual cost-cutting mechanism is a Claude Code plugin called "shunt." It works through two PreToolUse hooks that fire before every tool call:
- check-file-size blocks any file read exceeding a configurable line threshold — Mazmanov's default is 350 lines — and redirects it to a cheaper worker mode instead
- check-bash-read catches the same problem when it shows up as a bash command, watching for
cat,head,tail,less, andmoreon large files
The redirected work goes to two AiKA modes, both running Gemini 2.5 Flash at temperature 0.2: bulk-reader, described as a "bulk file reader for code analysis" that "delegates I/O from Claude Code" and is instructed to output "structured bullets only. No greetings, no prose, no preambles" — and code-writer, a "boilerplate code generator" instructed to "output only the code — no explanations, no markdown fences unless asked."
Where he says it doesn't work
Mazmanov doesn't hide the failure modes, and that honesty is exactly what makes the pattern sellable rather than hype:
- Editing tasks — "the worker model's summaries don't include reliable line numbers," so you can't safely hand off edits
- Reasoning work — on one real task, "the worker model found surface-level patterns but missed a subtle thread-safety bug"
- Small files — the 10–30 second round trip per delegation makes the pattern "counterproductive" when the file being read is already small
The business idea
Every team running Claude Code, Cursor, or a similar coding agent at real scale is somewhere on Mazmanov's own cost curve — most without ever having measured it. That's the audit:
- instrument a client's coding-agent usage with the same PreToolUse-hook pattern, logging which tool calls are burning the most tokens before recommending anything
- set a file-size threshold tuned to that specific codebase (not a copy-pasted 350 default) and route qualifying reads to a cheap worker model
- write the worker-mode prompts tightly — Mazmanov's "no greetings, no prose, no preambles" instruction is itself a big part of why the savings are real
- explicitly flag which of the client's workflows should stay on the primary model — editing, anything requiring line-accurate output, and genuine reasoning tasks — so the audit protects quality, not just cost
- re-run it monthly, since the right threshold shifts as a codebase's average file size changes
Why this works now
The spend numbers Mazmanov cites aren't hypothetical — a quarter of engineering leaders are already at $200–$500 per developer per month, some past $2,000, with costs projected to keep climbing past developer salaries by 2028. Almost none of those teams have someone whose job is specifically to audit where those tokens are going and fix the routing.
Bottom line
The 90% number is Mazmanov's, on his codebase. The pattern behind it — hook-based interception, a tuned size threshold, a cheap worker model, and honesty about where it breaks — is the reusable, sellable part.
Sources:
https://engineering.atspotify.com/2026/9/portal-by-spotify-cut-my-claude-code-token-usage-by-90
https://news.ycombinator.com/item?id=49571465
Tools mentioned
Related Playbooks
Google's TPU 8i Launch Points to a New AI Infrastructure Service: Agent Latency Audits and Inference Rebuilds for Teams Moving Into Multi-Agent Workflows.
Medium · 1-2 weeks to package the first audit offer and land a pilot
The Boring Internal Questions Business Is Still Wide Open. The Real Opportunity Is Private RAG for Teams That Hate Searching.
Medium · 2 weeks to first pilot
Mistral Published 'European AI: a playbook to own it.' The Business Opportunity Is AI Compliance and Procurement Infrastructure for Europe's Single Market.
Medium · 2-4 weeks to first pilot