# Spotify Portal Cuts Claude Code Token Usage by 90%

New solution optimizes AI coding costs with smart routing.

- **Source:** [Spotify Engineering](https://engineering.atspotify.com)
- **Published:** 2026-09-03
- **Topic:** [Data & AI](https://brifing.si/c/data-ai)
- **Original article:** <https://engineering.atspotify.com/2026/9/portal-by-spotify-cut-my-claude-code-token-usage-by-90/>
- **On Brifing:** https://brifing.si/s/9d6ce915-fa0a-4917-96ef-aba4ada1f950

## AI Coding Cost Crisis

By 2028, AI coding costs are projected to exceed developer salaries. Engineering teams currently spend $200-500 monthly per developer on tokens, with some exceeding $2000. The core issue is using overqualified models for simple I/O operations. Spotify Portal's new solution introduces a dual-mode approach to address this wasteful token consumption and rising costs.

## How Modes Work

Portal's AiKA modes provide ephemeral declarative agents. Users can define instructions and select models to create modes. These operate on a Lambda-like runtime specifically for agents. Each mode has its own instructions, model, and parameters. Modes are callable via Portal CLI or API and can be shared company-wide. The system requires no long-running server management.

## Bulk-Reader Mode

The Bulk-Reader mode handles large file reading tasks instead of Claude. It uses cheaper models like Gemini 2.5 Flash to optimize file operations. The mode provides precise answers with structured bullets, eliminating unnecessary explanations. By preventing Claude from reading large files for simple queries, it achieves significant token savings.

## Code-Writer Mode

Code-Writer generates predictable outputs like test files and scaffolding. It strictly follows patterns and styles from reference files, outputting only code without explanations. This mode reduces Claude's workload for boilerplate generation. Particularly in large projects, it saves considerable time and tokens when creating repetitive code blocks.

## Shunt Plugin

The shunt plugin automatically routes Claude Code's tool usage. It offers two PreToolUse hooks: check-file-size and check-bash-read. The former blocks large file reads and redirects to bulk-reader mode. The latter catches bash commands on large files. The SHUNT_MIN_LINES environment variable configures the threshold, centralizing delegation rules.

## Bash Script Integration

The system completes with two bash scripts: bulk-read and code-write. bulk-read wraps files in XML tags for the bulk-reader mode. code-write sends specs and references to the code-writer mode. The scripts handle request building, error processing, and token usage reporting. Claude never sees generated code, preventing context consumption.

## Mode Resolution System

Portal's mode resolution system follows user priority. Modes are called by name, checking user-specific modes first, then team modes, then public ones. Forking public modes for customization is supported, with customized versions automatically taking precedence. This creates a flexible yet centralized mode management approach.

## Cost Benefits

This system can reduce token costs by up to 90%. By using cheaper models for simple I/O, it reserves Claude for complex problems only. Ephemeral invocations mean nothing is stored server-side. For large codebases, monthly savings can reach thousands of dollars. This solution proves particularly valuable for large engineering teams.

## Sources covering this story

- https://engineering.atspotify.com/2026/9/portal-by-spotify-cut-my-claude-code-token-usage-by-90/ — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
