nayaread
HomeFavouritesTopicsSources
HomeFavouritesTopicsSources
NayaRead links to original engineering blogs. All copyright belongs to the respective authors.
Spotify Engineering·Sep 3, 2026·8 min read·Spotify Engineering59

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

Most of what an AI coding agent does for me isn't thinking. It's I/O. The post Portal by Spotify cut my Claude Code token usage by 90% appeared first on Spotify Engineering.

AILLMs
AI summarygenerated from the source article

Offloading bulk file reads and boilerplate generation to cheap worker models cut Claude Code token consumption by 90%. 👇

Most of what an AI coding agent does isn't heavy thinking—it's raw I/O. Frontier models burn thousands of expensive tokens reading hundreds of lines of code just to answer a simple question, or generating repetitive test boilerplate. Engineering teams regularly spend $200 to over $2,000 per developer every month feeding overqualified models basic grunt work.

An engineer at Spotify built `shunt`, a Claude Code plugin that intercepts heavy file reads and boilerplate generation, routing those tasks through Portal by Spotify to cheap worker models like Gemini 2.5 Flash.

The mechanism uses a three-layer pipeline:

Layer 1: PreToolUse Hooks. Every time Claude attempts a tool call, `check-file-size` and `check-bash-read` hooks inspect the request. If a file exceeds a threshold (default: 350 lines), the hook blocks direct execution and forces delegation. Targeted reads with line offsets pass through uninterrupted.

Layer 2: Execution Scripts. Custom bash scripts wrap Portal CLI actions. The `bulk-read` script packs files into XML boundaries and routes them to a worker model, returning a concise summary. The `code-write` script sends a specification and reference file to the worker, stripping prose markdown and writing output directly to disk—so Claude never consumes tokens for the generated code.

Layer 3: Skills Redirects. Markdown skill files supply Claude with explicit invocation syntax. When a hook blocks an expensive call, the block message points Claude directly to the skill instructions to execute the redirect.

The workflow explicitly keeps complex reasoning with Claude. cheap worker models missed subtle thread-safety bugs in testing and struggled with line-number precision, so architectural edits and debugging remain strictly in Claude's hands.

In benchmarks across a Java monorepo, delegating bulk reads reduced Claude's token usage by 90%. Boilerplate generation completely bypassed Claude's context window, with delegated round-trips taking between 10 and 30 seconds.

Read original on engineering.atspotify.com

Discussion around the web

  • Hacker News278 · 178 💬

Score breakdown

  • Technical depth80
  • Practical value30
  • Originality85
  • Writing quality100
  • Source reputation0
  • Recency97
  • External engagement36
  • On-site engagement36

NayaRead shows a summary and links to the original article. The full article is hosted on engineering.atspotify.com.

More like this

Shopify Engineering

Remixing Shopify's Admin: How We Made It 30% Faster and AI-Ready (2025) - Shopify

Jun 30, 2025·9 min read
Stripe Engineering

Using AI agents to build Stripe-Salesforce integrations faster

Vishnu Samavedula·Apr 13, 2026·1 min read
Shopify Engineering

Building a Magic Mirror: AI retail experiences with Remix (2026) - Shopify

Mar 19, 2026·11 min read
Stripe Engineering

What it feels like building with Stripe Projects

Ben Smith·May 26, 2026·2 min read