shunt
A Claude Code plugin that shunts I/O-heavy reading to a cheaper worker model, so a large
file corpus never enters Claude's context.
This is an adaptation of Spotify's shunt plugin,
which delegates to AiKA modes through the Portal CLI. This version keeps the hook and skill
design and swaps the transport for a local coding-agent CLI: pi
or codex. It is read-only — the original's
code-writer half is not ported.
How it works
Three layers, from hard gate to soft suggestion:
- Hooks block Claude from reading large files and redirect to the bulk-reader skill
- Scripts handle the worker invocation and output cleanup
- Skills tell Claude when and how to call the scripts
Claude never assembles bash pipelines from prose. It calls a script with named arguments.
The scripts handle everything internally.
The corpus travels to the worker on stdin, so there is no payload ceiling to work
around. Everything backend-specific lives in scripts/lib/worker.sh behind a single
shunt_invoke function; the hooks, skills, and bulk-read itself are backend-agnostic.
Prerequisites
jq — brew install jq
- One worker CLI, already authenticated:
pi (default) — npm i -g @earendil-works/pi-coding-agent
codex — npm i -g @openai/codex
perl is used to enforce the invocation timeout, since macOS ships no timeout(1).
timeout or gtimeout are used instead when present.
Install
The repository doubles as a single-plugin marketplace:
claude plugin marketplace add 0x7067/shunt
claude plugin install shunt@shunt
Scripts
bulk-read
Delegates file reading to the worker model. Files are wrapped in XML tags
(<file path="...">) for clear boundaries.
bulk-read --question "What does this service do?" --paths src/Service.java src/Handler.java
# Follow-up: ask again with the same paths
bulk-read --question "Which methods call the database?" --paths src/Service.java src/Handler.java
The bulk-reader instructions live in scripts/prompts/bulk-reader.md. Edit that file to
change how the worker answers.
shunt-toggle
The per-session escape hatch. Reachable from Claude as /shunt on|off|status.
shunt-toggle status --session "$CLAUDE_SESSION_ID"
shunt-toggle off --session "$CLAUDE_SESSION_ID"
shunt-toggle on --session "$CLAUDE_SESSION_ID"
off drops a marker in ${SHUNT_STATE_DIR:-~/.cache/shunt}/off/<session-id> that the hooks
check before blocking anything. With no session id available, the marker is named global
and turns shunt off everywhere.
One shot per call
Every delegation stands alone. Nothing is stored on either side, and the only way to carry
context across calls would be to replay the corpus — which is the exact cost this plugin
exists to avoid. Re-sending files is free where it matters, because they go to the worker
model and never enter Claude's context.
Hooks
check-file-size (Read hook)
Fires on every Read tool call. Blocks full-file reads on files exceeding SHUNT_MIN_LINES
(default: 350). Allows through:
- Targeted reads (offset or limit set)
- Files under the threshold
- Nonexistent files (let Read handle the error)
check-bash-read (Bash hook)
Fires on every Bash tool call. Catches cat, head, tail, less, more on large
files. Allows through:
- Piped commands (
cat file | grep) — targeted reads
- Redirections (
cat file > out) — not reading into context
- Commands with flags that indicate targeted reads
- Non-read commands (
git status, grep, etc.)
Configuration
All settings are environment variables — add them to the env block in
.claude/settings.json.
| Variable | Default | Purpose |
|---|
SHUNT_BACKEND | pi | Worker CLI to delegate to: pi or codex |
SHUNT_MIN_LINES | 350 | Line count above which the Read hook blocks and redirects |
SHUNT_TIMEOUT_SECONDS | 180 | Ceiling for one delegation |
SHUNT_PI_MODEL | pi's default | --model for the pi backend |
SHUNT_PI_PROVIDER | pi's default | --provider for the pi backend |
SHUNT_CODEX_MODEL | codex's default | -m for the codex backend |
SHUNT_OFF | unset | Set to any value to disable the hooks outright |
SHUNT_STATE_DIR | ~/.cache/shunt | Where the per-session off markers live |
Pick a small, cheap model for the worker. The default for each CLI is whatever that CLI is
already configured to use, which may be larger than this job needs.
Plugin structure