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.
More from coding & agent
- Claude Code team reportedly ditched GUI/TUI, now using claude tag for 70%+ of work — himanshustwts · 2026-09-07
- Microsoft open-sources tgrep, a trigram-indexed grep up to 52x faster than ripgrep — jedisct1 · 2026-09-07
- How should billing work when an AI system auto-selects the model? — Colddew-YJ · 2026-09-07
- SmolVM: open-source microVM sandbox runs OpenClaw 2.0 in isolation, boots in milliseconds — aniketmaurya · 2026-09-07
- Researchers formalize the AI agent attack surface: models + data + tools + permissions — JayAlammar · 2026-09-07
- Developer vibe-codes an interactive Odyssey narrative scroller with GPT-6 Astra — Pristine_Good7326 · 2026-09-07