To combat escalating AI coding costs, Spotify developed a routing system using Portal's AiKA "modes" to offload repetitive I/O and boilerplate tasks from expensive frontier models to cheaper worker models like Gemini 2.5 Flash. By implementing the "shunt" Claude Code plugin, the developer achieved a 90% reduction in token usage for bulk file reading. The system operates through three layers: PreToolUse hooks that intercept large file reads (exceeding a configurable line threshold via SHUNT_MIN_LINES), bash scripts that wrap Portal CLI calls, and Claude "skills" that guide the agent on how to use these new tools. Specifically, the "bulk-reader" mode handles multi-file analysis by providing structured summaries, while the "code-writer" mode generates boilerplate by matching patterns from reference files and writing directly to disk, preventing expensive output tokens from ever entering the Claude context. While effective for I/O and pattern-based generation, the system is not intended for reasoning, debugging, or editing, as the worker models lack the precision required for line-specific edits and the process introduces a 10–30 second network latency per delegation.
Read original
hackernews