Spotify engineer's Claude Code hook cuts token spend 90% by rerouting big file reads to Gemini

RexDouglass · x · 2026-09-07

A Spotify engineer built a Claude Code plugin that blocks large file reads at the hook layer and reroutes them to a cheap Gemini worker instead of Claude, measuring a 90% drop in token spend on one Java monorepo.

Key lesson: his first version put routing advice in CLAUDE.md, which Claude simply ignored. The hook works because it doesn't ask — it blocks. The pattern of enforcing behavior via hooks rather than instructions applies broadly to coding-agent cost optimization.

Original post →

More from coding & agent

coding & agent channel →