Spotify cut Claude Code token usage by 90% by routing big file reads to cheap models
aliscodes · x · 2026-09-07
Spotify engineering explains how they stopped Claude from burning frontier tokens on grunt work. Most agent work is I/O—reading files, generating boilerplate tests, updating docs—so they built a plugin called shunt with two cheap workers (Gemini 2.5 Flash in examples):
- bulk-reader: opens long files and returns terse bullets with exact names, types, and line numbers—no prose;
- code-writer: dumps generated files straight to disk so Claude never re-reads its own output.
The key lesson: hooks beat instructions. Rules written into claude.md telling Claude to use cheap workers were ignored—Claude read the files anyway. So they blocked reads at the system level: any file over 350 lines gets routed to bulk-reader, cat/head/tail on big files are blocked, while offset-based slice reads still pass through.
Results and costs: on a 162,000-line Java repo, three bulk-read tests cut context entering Claude by 82%, 94%, and 94% (tokens into Claude, not the whole bill). The expensive model stays on edits, bugs, architecture, and safety-critical work—in one case a cheap worker missed a thread-safety bug that Claude caught once given the right slice. Each handoff adds 10–30 seconds, so small files aren't worth routing. A lighter no-plugin version: have a cheap model skim docs into bullets, then hand the brief plus one pasted slice to the expensive model.
Related event: Spotify's Shunt Cuts Claude Code Token Costs by ~90% via Model Routing(6 posts)→
More from coding & agent
- Indie dev's agent tracks 519 directories, 311 submitted for SEO backlinks — fekdaoui · 2026-10-23
- ScienceClaw Hackathon at MIT Media Lab to build decentralized AI agent collectives for science — ProfBuehlerMIT · 2026-10-23
- What should a native agent harness handle beyond tool calling? — Glittering812 · 2026-10-23
- Running ~100 DeepSeek v4.1 flash agents in parallel for under $20/month — zack_overflow · 2026-10-23
- MCP's stateless 2026-07-28 spec drops session-id — how are stateful tools adapting? — Stock-Pumpkin-8859 · 2026-10-23
- Dev adds local MCP server to Mac screenshot app so Claude designs from your references — Embarrassed-Ebb-740 · 2026-10-23