Stop burning frontier tokens on large file reads: hook your coding agent so files over a line limit go to a cheaper bulk-reader worker that returns structured bullets—keep the expensive model for edits and real reasoning: AI agent prompt
Spotify Engineering (Sep 3, 2026) published how Dimitri Mazmanov cut Claude Code token use on large reads by about 90% with Portal AiKA modes and a Claude Code plugin called shunt. PreToolUse hooks block full reads (and bash cat/head/tail) of files over a configurable line threshold (default 350) and redirect to a bulk-reader mode on a cheaper worker model (example: Gemini 2.5 Flash) that returns concise structured bullets. A code-writer mode can scaffold tests/config from a reference file so Claude never ingests the generated output. Targeted offset/limit reads still pass for edits. They warn: don’t delegate debugging or safety-critical reasoning; latency is 10–30s per call. Install steps use the spotify/portal-ai-plugins marketplace; confirm Portal access before relying on it.
The prompt
1. Measure last week’s coding-agent spend and note how often it fully reads files over ~350 lines. 2. Add a pre-read hook (or standing rule) that blocks full reads of large files and instead calls a cheaper worker with: the file(s), your question, and “structured bullets only, lead with exact names/line numbers.” 3. Keep offset/limit and grep-style reads on the main agent so it can still edit precise sections. 4. Optionally add a boilerplate writer that takes a spec + one reference file and writes tests/config to disk without pasting the whole output into the main chat. 5. Compare tokens and answer quality on the same multi-file question before and after for a few days; raise the line threshold if small-file latency isn’t worth it.
How to use it
- Copy the prompt above.
- Replace every [bracket] with your own details (or fill in the blanks on AgentPlaybook Real Estate, which remembers your answers for the next prompt).
- Paste it into Claude Code (hooks/plugins), Spotify Portal AiKA modes / shunt plugin (or any cheaper worker model + CLI), optional Gemini Flash and review the answer before you use it.
Works with: Claude Code (hooks/plugins), Spotify Portal AiKA modes / shunt plugin (or any cheaper worker model + CLI), optional Gemini Flash
Real-world example: engineering.atspotify.com/2026/09/portal-by-spotify-cut-my-claude-code
Before you use it: what to check
Check yourself
- Check names, dates, numbers and any claim against your own source material before you use the answer. AI can misread or invent details.
Using an AI agent? Download this prompt as a SKILL.md agent skill with these checks built in, or get the .zip for Claude.ai. How to install skills.
Want to make this prompt even better? Grade it with the free prompt grader or build your own with the AI prompt generator.
32 copy-paste agent prompts (PDF) plus 5 new prompts every week.
Get it free