Skip to content

Build1 publisher3 min readPublished

Spotify's shunt hook blocks non-targeted Claude Code file reads past a configurable line threshold

The 90 percent token saving is one engineer's own usage on his own repos, but the enforcement mechanism underneath it copies cleanly: a line-count threshold that returns a block, with a pipe-shaped hole in it.

The Engineer · Build desk

What happened

  • A Spotify engineer reports that delegating bulk file reads and boilerplate generation to Gemini 2.5 Flash through Portal's AiKA Modes cut his Claude Code token usage by 90 percent.
  • The shipped version is a Claude Code plugin called shunt, whose PreToolUse hook blocks any Read of a file longer than a configurable default of 350 lines and redirects it to the bulk-reader mode.
  • The post's cost frame cites a quarter of engineering leaders spending $200 to $500 per developer per month on tokens, with some well past $2,000.

Compiled by The EngineerSomething wrong?How this is made

Why it matters

  • constraint The no-platform-team framing holds only for teams that already run a Portal instance with the AiKA plugin enabled, since delegation goes through the Portal CLI actions registry. Without that runtime, you are hosting the worker modes yourself before you save a token.
  • decision Teams writing agent cost policy now have a worked case for putting it in a blocking hook rather than a prompt file, which turns the read threshold into a tunable someone has to own and defend.
  • cost Because the saving comes from moving tokens rather than removing them, it survives only if the cheap model stays terse; a worker that adds fences and commentary charges you for the same content twice.

When check-file-size fires on a Read call, the read does not happen. The hook blocks it and returns a message telling Claude to use the /bulk-reader skill instead [11]. Targeted reads pass through untouched, on the reasoning that Claude already knows which section it wants [11]. That block is the whole difference from the first attempt, which put the same policy in CLAUDE.md, where by the author's account the rules were advisory, Claude could ignore them, and every project needed its own copy [8]. Instructions ask; a PreToolUse hook returns a verdict, and hooks fire before every tool call [10].

The routing criterion is file length: 350 lines by default, overridable with SHUNT_MIN_LINES in a shell profile or .claude/settings.json [11][13]. Line count is a cheap proxy for how much reasoning a file needs, and a rough one. A dense 400-line parser goes to Flash; a 300-line one stays with the frontier model. The bash-side rule has a shape worth knowing too. check-bash-read intercepts cat, head, tail, less and more on large files, but lets piped commands through on the grounds that they are targeted reads [12]. By that definition, appending a pipe converts a blocked read into an allowed one.

Delegation moves tokens rather than deleting them. The worker model reads the file body at its own rate, then Claude pays frontier input rates for the bullets that come back. Which is why "output only the code" is the load-bearing line in the code-writer instructions: the post notes that without it the model wraps output in markdown fences and explanatory prose that Claude then has to parse [14][15]. Worker verbosity is billed twice, once as output and again as input.

The cost frame in the post is a survey figure, not the author's bill. A quarter of engineering leaders already spend $200 to $500 per developer per month on tokens, and some are well past $2,000 [3]. Take that top cohort literally and it is roughly $24,000 per developer per year; hold the 90 percent and it lands near $2,400 [1]. The 90 percent itself is one engineer reporting on his own workload, with no before-and-after token counts published in the post [1]. For the ratio to transfer, your spend has to be dominated by whole-file reads and pattern-copy generation rather than debugging, your files have to be long enough to trip the threshold, and the worker output has to be accurate enough that Claude does not quietly redo it.

The post says the fix needed no platform team and no new subscription [4]. It does need a Portal instance with the AiKA plugin enabled, because delegation runs through the Portal CLI actions registry [9], and a mode whose model field points at something already configured in that instance [6]. Portal supplies the ephemeral runtime, described in the post as AWS Lambda but for agents, and keeps the API keys out of the client [5]. The excerpt does not state whether Portal is available outside Spotify, or on what terms [17]. What copies without it is the enforcement layer: two PreToolUse hooks, a pair of shell wrappers, and any cheaper model reachable from a CLI [10][16].

What to watch

  • Whether Spotify states Portal's availability and terms outside Spotify, which decides who can run AiKA Modes at all.
  • Whether shunt's routing criterion gains anything content-aware beyond a raw line count, and whether the pipe pass-through gets tightened.
  • Whether the plugin and a measured token baseline are published, so the 90 percent can be reproduced on someone else's repo.
Loading claim ledger
Loading source directory links
Loading share composer
Loading topic controls
Loading related stories