SYSTEM Cited by 1 source
shunt (Claude Code plugin)¶
shunt is a Claude Code plugin (open-sourced by Spotify under
spotify/portal-ai-plugins) that enforces model routing for a coding agent:
it intercepts expensive I/O tool calls and redirects them to cheaper
Portal AiKA Modes instead of letting them run
against the frontier model. Delegation goes through the Portal CLI actions
registry, so shunt works against any Portal instance with the AiKA plugin
enabled
(Source: sources/2026-09-03-spotify-portal-by-spotify-cut-my-claude-code-token-usage-by-90).
An earlier version was just a block of routing rules in CLAUDE.md, but those
rules were advisory (Claude could ignore them) and had to be copied per project.
shunt makes the routing enforced and centrally installed.
The three layers¶
shunt is a canonical instance of layered graceful-degradation enforcement: each layer works even if the layer above is skipped.
- Hooks (enforcement). Two
PreToolUsehooks fire before every tool call: check-file-size— on everyRead; if the file exceeds a configurable line threshold (default 350,SHUNT_MIN_LINES), the hook blocks the read and tells Claude to use the/bulk-readerskill. Targeted reads pass through (Claude already knows the section it needs).check-bash-read— catchescat,head,tail,less,moreon large files. Piped commands (cat file | grep) pass through as targeted reads.- Threshold is configurable via
SHUNT_MIN_LINESin the shell profile or.claude/settings.json. - Scripts (mechanism). Two bash wrappers around the Portal CLI:
bulk-read --question ... --paths ...— wraps each file in XML tags for clear boundaries and sends them with the question to thebulk-readermode. Re-sending the same paths on a follow-up is free where it matters: the corpus goes to the worker, never into Claude's context.code-write --spec ... --reference ... --target ...— sends a spec + a required reference file to thecode-writermode, strips markdown fences, and can write straight to disk. The reference is required so the worker matches project patterns instead of generating context-free code.- Both report token usage to stderr and unwrap errors internally.
- Skills (guidance). Two markdown skill files tell
Claude when and how to call the scripts. When a hook blocks a read, its
message points Claude at the
/bulk-readerskill, which shows the exact invocation syntax. The skill only makes the redirect smoother — the hook already enforces it.
What it deliberately does not route¶
shunt encodes the I/O-vs-reasoning boundary directly:
- No delegated editing — worker summaries lack reliable line numbers, so edits still need Claude to read the specific section (hooks allow targeted offset/limit reads for exactly this).
- No delegated reasoning — debugging, architectural decisions, and safety-critical code stay on the frontier model (the worker missed a subtle thread-safety bug Claude caught).
- Latency floor — each delegation is a 10–30s round-trip (Portal caps a single invocation at 30s), so the line threshold prevents delegating small reads where overhead would exceed savings.
Seen in¶
- sources/2026-09-03-spotify-portal-by-spotify-cut-my-claude-code-token-usage-by-90 — the plugin behind a ~90% bulk-read token saving; three layers (hooks, scripts, skills) that degrade gracefully.
Related¶
- systems/portal-by-spotify — the modes shunt delegates to
- systems/github-copilot — Claude Code, the frontier client shunt wraps
- agent-skill — the skill layer
- hook-blocks-expensive-tool-call-redirects-to-cheaper-mode
- layered-graceful-degradation-enforcement
- delegate-io-to-cheaper-worker-model
- companies/spotify