Spotify Portal shunt: cut Claude Code tokens 90% via bulk-reader + code-writer AiKA modes (extracted from tweet + Spotify Engineering) Spotify Engineering cut Claude Code token usage by roughly 90% on a Java monorepo by routing bulk file reading and boilerplate code generation to a cheap model such as Gemini 2.5 Flash while keeping reasoning on frontier models like Claude Opus and Sonnet. The setup, built on Spotify's Portal AiKA Modes, relies on a blocking PreToolUse hook that hard-blocks reads over 350 lines rather than relying on written routing instructions, which the team found were ignored. Spotify's takeaway: "Written rules are a suggestion. A block is not. Original: Spotify's Claude Code setup @undefinedKi tweet https://x.com/undefinedKi/status/2095942506433089832?s=20 + Spotify Engineering, Sep 3 2026 https://engineering.atspotify.com/2026/9/portal-by-spotify-cut-my-claude-code-token-usage-by-90 . Generalized below for GitHub Copilot, Kiro, and Codex OpenAI Codex CLI . Route grunt I/O to cheap model, keep reasoning on frontier, enforce with a hard block 350 lines , not prompt instructions. Spotify: Claude Opus/Sonnet + Gemini 2.5 Flash via Portal AiKA Modes → ~90% token savings on Java monorepo. Same pattern works anywhere if you add 3 layers: 1 Blocking interceptor 2 Cheap-worker scripts/MCP 3 Redirect instructions. Use any cheap/fast model: gemini-2.5-flash / claude-haiku / gpt-4o-mini / gpt-4.1-nano / ollama/qwen2.5-coder . Temp 0.2 . 1. bulk-reader — reads N files, returns bullets. Frontier never sees full files. You are a precise code analyst. Read the provided files and answer the question concisely. Output structured bullets only. No greetings, no prose. Lead every bullet with exact name/type/line. Use nested bullets for details. Skip anything not asked. 2. code-writer — generates boilerplate from spec + reference, writes to disk. You generate code files based on a spec and reference files. Match existing patterns, conventions, naming, style exactly. Output only the code — no explanations, no markdown fences unless asked. If ambiguous, choose what matches reference. Spotify's Portal AiKA Modes implement these as name: bulk-reader / code-writer with model: gemini-2.5-flash . You can replace with a direct API call — see self-hosted script below. Invocation contract tool-agnostic : bulk-read --question "What does this service do?" --paths src/A.java src/B.java code-write --spec "Write tests for UserService" --reference tests/OrderTest.java --target tests/UserTest.java bulk-read wraps files in XML tags for boundaries; code-write strips fences and can write to --target | Layer | Purpose | Claude Code Spotify | Generalized | |---|---|---|---| | 1. Hook / Enforcement | Hard block, not suggestion | PreToolUse hooks: check-file-size SHUNT MIN LINES=350 + check-bash-read cat/head/tail | See per-tool below | | 2. Scripts / MCP | Call cheap model, handle XML/fences, report tokens | bulk-read / code-write bash wrappers over portal CLI | Same scripts, but call curl to cheap model OR Portal CLI OR MCP server | | 3. Skills / Instructions | Tell agent when/how to redirect | /bulk-reader skill md + block message | copilot-instructions.md / .kiro/steering/ / AGENTS.md — but always paired with Layer 1 | Lesson from Spotify: "Written rules are a suggestion. A block is not." CLAUDE.md routing was ignored until they added blocking hooks. 1. Editing — summaries lack reliable line numbers → keep targeted read offset,limit on frontier. 2. Reasoning/debugging/architecture/thread-safety — cheap model missed subtle bug frontier caught in seconds. 3. Small files — delegation overhead 10–30s + 30s cap; threshold exists for this reason. Replace Portal with 20 lines of bash. Works for all tools: bash /usr/bin/env bash bulk-read — generic version, swap MODEL/endpoint as needed set -euo pipefail QUESTION="$1"; shift FILES= "$@" Build XML payload PAYLOAD="" for f in "${FILES @ }"; do PAYLOAD+="