claude-code

Spotify's shunt blocks Claude Code reads over 350 lines

Claude News

claude-code

A Claude Code plugin called shunt blocks any file read over 350 lines and routes the work to a cheaper worker model, cutting bulk-read token consumption by roughly 90% on average across four scenarios tested on a Java monorepo. The plugin and the benchmark were published by Atspotify.

At a glance

  • Two PreToolUse hooks do the enforcing: check-file-size blocks whole-file reads past the threshold, while check-bash-read catches cat, head, tail, less and more, letting piped and targeted reads through.
  • Delegation goes to two public Portal by Spotify modes running Gemini 2.5 Flash at temperature 0.2, with each invocation ephemeral and capped at 30 seconds by the Portal backend.
  • A quarter of engineering leaders already spend $200–$500 per developer per month on tokens, some are past $2,000, and AI coding costs are expected to exceed the average developer salary by 2028.

Token spend, not seat licences, is where agentic coding gets expensive, and the shunt design reads as an admission that most agent work is I/O rather than reasoning. Routing that traffic to a configured worker mode likely matters more as a pattern than as a plugin: the decision of when to delegate sits in the client, while how the worker responds sits in a mode that can be swapped without touching the plugin.

A default 350-line threshold decides what Claude Code reads directly

The enforcement sits in two PreToolUse hooks. check-file-size fires on every Read call and blocks it when a file exceeds a configurable line threshold, default 350, pointing Claude at the /bulk-reader skill instead, while check-bash-read catches cat, head, tail, less and more on large files.

Targeted reads pass through, as do piped commands such as cat file | grep. The threshold moves via the SHUNT_MIN_LINES environment variable, set in a shell profile or in .claude/settings.json. Two bash scripts wrap the Portal CLI calls, and two skill files tell Claude when and how to invoke them.

The first version was a block of routing rules in CLAUDE.md. Those rules were advisory rather than enforced, Claude could ignore them, and each project needed its own copy, whereas the hook layer still blocks an expensive read even if the skill description goes unread.

Both worker modes run Gemini 2.5 Flash at temperature 0.2

bulk-reader and code-writer are AiKA modes in Portal by Spotify, declarative agents on an ephemeral runtime where the caller defines instructions, picks a model, sets parameters such as temperature and attaches MCP tools. Both are public, and the model field accepts any model configured in a given Portal instance.

The bulk-read script wraps each file in XML tags and sends them with the question. The invocation is ephemeral, nothing is stored server-side, and the file corpus never enters Claude's context. code-write takes a spec and a required reference file, strips markdown fences and can write straight to disk.

Modes resolve by name, case-insensitively, preferring the caller's own mode, then the team's, then public ones, so a forked bulk-reader takes precedence without configuration. The instruction to output only the code matters: without it the model returns markdown fences and prose that Claude then has to parse.

Editing and debugging stay with Claude, and each call costs 10–30 seconds

Worker summaries do not carry reliable line numbers, so edits still require Claude to read the specific section, which is why the hooks allow targeted reads with offset and limit. In testing the worker found surface-level patterns but missed a thread-safety bug that Claude identified once given the right context.

The routing therefore excludes debugging, architectural decisions and safety-critical code. Each delegation is a network round trip from Claude Code to the Portal backend to the worker model, typically 10–30 seconds, and Portal caps one invocation at 30 seconds, so very large generations have to be split into smaller calls.

The code-write path is harder to quantify, because without the plugin Claude reads the reference files and emits the generated file as output tokens, while with it the code goes to disk unseen. The reported mean saving of about 90% covers the bulk-read scenarios.

Installing shunt and forking the modes

Both plugins install from the spotify/portal-ai-plugins marketplace: claude plugin marketplace add spotify/portal-ai-plugins, then claude plugin install portal@portal and claude plugin install shunt@portal. The portal plugin supplies the CLI that shunt delegates through, and /portal:setup authenticates it against a Portal instance. The bulk-reader and code-writer modes already exist publicly, and the post gives no per-scenario breakdown behind the 90% mean.

Comments

No comments yet. Be the first.

Join the conversation

Sign in with Google to leave a comment. Your name and avatar come from your Google profile, and the comment appears after moderation.

We only use your name and avatar from Google. We never store your email address.