---
title: "Portal by Spotify cut my Claude Code token usage by 90%"
description: "Claude Code often spends frontier-model tokens on file I/O and predictable code generation rather than reasoning, motivating a routing setup built with Portal by Spotify’s AiKA Modes. The implementation defines two public modes—bulk-reader for multi-file analysis and code-writer for pattern-based generation—both shown with Gemini 2.5 Flash, while a Claude Code plugin named shunt enforces delegation through hooks, scripts, and skills. PreToolUse hooks block large Read and shell-based file reads above a configurable threshold, while scripts send files or references to ephemeral worker invocations without exposing the full file corpus or generated code to Claude’s context. In a Java monorepo benchmark, mean bulk-read savings were around 90%, although code-write savings were harder to measure. The approach does not suit editing or reasoning tasks: worker summaries lacked reliable line numbers, missed a subtle thread-safety bug, and added 10–30 seconds of latency, so targeted reads and Claude’s reasoning remain necessary."
---

# Portal by Spotify cut my Claude Code token usage by 90%

[Spotify](https://yomu.fyi/company/spotify) · Spotify Engineering · Sep 3, 2026

**Type:** Problem & solution

## Summary

Claude Code often spends frontier-model tokens on file I/O and predictable code generation rather than reasoning, motivating a routing setup built with Portal by Spotify’s AiKA Modes. The implementation defines two public modes—bulk-reader for multi-file analysis and code-writer for pattern-based generation—both shown with Gemini 2.5 Flash, while a Claude Code plugin named shunt enforces delegation through hooks, scripts, and skills. PreToolUse hooks block large Read and shell-based file reads above a configurable threshold, while scripts send files or references to ephemeral worker invocations without exposing the full file corpus or generated code to Claude’s context. In a Java monorepo benchmark, mean bulk-read savings were around 90%, although code-write savings were harder to measure. The approach does not suit editing or reasoning tasks: worker summaries lacked reliable line numbers, missed a subtle thread-safety bug, and added 10–30 seconds of latency, so targeted reads and Claude’s reasoning remain necessary.

## Context

AI coding agents spend substantial token budgets on input/output work such as reading multiple files, reproducing established test patterns, and updating documentation. The post frames these tasks as poor uses of an expensive frontier model and reports that token costs can reach hundreds or thousands of dollars per developer per month.

## Approach / What changed

Two Portal AiKA Modes delegate predictable work to Gemini 2.5 Flash: bulk-reader summarizes multi-file analysis, while code-writer generates pattern-matching code. The shunt Claude Code plugin uses PreToolUse hooks, shell scripts, and skills to route large reads and boilerplate generation through the Portal CLI, while allowing targeted reads to pass through.

## Takeaways

- AiKA Modes are declarative agents running on ephemeral runtimes; their configuration includes instructions, a model, parameters such as temperature, and MCP tools, and they are callable through the Portal CLI or API.
- Shunt’s default large-file threshold is 350 lines. SHUNT\_MIN\_LINES can change it, and targeted reads using offsets or limits are allowed so Claude can inspect precise sections directly.
- Delegation is unsuitable for editing and reasoning-heavy work: summaries may lack reliable line numbers, the worker missed a subtle thread-safety bug, and each invocation typically adds 10–30 seconds of latency.

**Tags:** [AI Agents](https://yomu.fyi/topic/ai-agents), [Claude Code](https://yomu.fyi/topic/claude-code), [Model Routing](https://yomu.fyi/topic/model-routing)

- Source: [Spotify](https://engineering.atspotify.com/2026/9/portal-by-spotify-cut-my-claude-code-token-usage-by-90)
- Source URL: https://engineering.atspotify.com/2026/9/portal-by-spotify-cut-my-claude-code-token-usage-by-90
- Ingested by Yomu: 2026-09-04T00:00:47.476Z

[Read original post](https://engineering.atspotify.com/2026/9/portal-by-spotify-cut-my-claude-code-token-usage-by-90)
