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):

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 Cuts Claude Code Token Costs 90% by Offloading File Reads to Cheaper Models(3 posts)→

Original post →

More from coding & agent

coding & agent channel →