> ## Documentation Index
> Fetch the complete documentation index at: https://agent-harness101.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Enforce with a hook

> A prompt-based instruction is a suggestion. A hook enforces it in code.

## The question

Why not just tell the agent in the system prompt to use the cheaper model?

## The answer

A prompt-based instruction is a suggestion. A hook enforces it in code.

A system-prompt instruction is a suggestion the model can drift from under a long, noisy context — and there’s no way to verify it was followed. A **PreToolUse hook** runs synchronously in the execution path itself, before the tool call fires, so it can inspect the call and block, modify, or reroute it — compliance isn’t optional.

* **90%** — fewer tokens when a large file read is delegated instead of handled by the frontier model itself

* **350 lines** — a read request above this size is what automatically triggers the reroute

* **10–30s** — added latency per delegated call

```mermaid theme={null}
flowchart TD
n0["read_file"]
n1["PreToolUse hook · Claude Code"]
n0 --> n1
```

* Targeted read (offset/limit) → frontier model

Claude already knows what it needs — reading it directly is correct and cheap.

* Untargeted, >350 lines → cheap worker

Volume is the cost, not judgment — the hook blocks this automatically.

* Edit / debug / architecture → frontier model

Excluded by design, not detected per-call — the worker missed a bug the frontier caught in seconds.

<Warning>
  **Not built into Claude Code.** The hook mechanism is native; this specific router (Spotify’s *shunt* plugin) is a third-party layer on top of it, tuned to one Java monorepo — treat the 90% as that team’s result, not a universal one.
</Warning>

### Source

[Spotify Engineering — Portal / shunt, Sept 2026](https://www.engineering.atspotify.com/2026/9/portal-by-spotify-cut-my-claude-code-token-usage-by-90) — Gemini 2.5 Flash worker model · self-reported, four-scenario benchmark.

## Continue the walkthrough

<Card title="Conditional planning" icon="arrow-right" href="/planning/conditional-planning">
  Continue to topic 8 of 14.
</Card>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.