Pins every subagent to the fable model: rewrites the model on agent.spawn unless the spawn is a fork, with /fable-pin on, off and status. Touches nothing but…

Every subagent runs on the model you chose, not the one a prompt asked for. This mod rewrites model on agent.spawn to fable unless the spawn is a fork, which inherits the parent's model anyway. /fable-pin off turns it off for the session and remembers that, /fable-pin on turns it back on, /fable-pin status says which.
Why it exists: a standing rule such as "every agent runs on fable" lives in a settings file that the model reads and sometimes ignores. A hook on agent.spawn cannot be ignored. The Agent tool's own model parameter is what gets rewritten, so the subagent's transcript shows the pinned model as its own.
Validated on Claude Code 2.1.272:
❯ ./register.ts hooks: session.start, command.run{command=fable-pin}, agent.spawn ❯ ./register.ts calls: $.command.register, $.store.get, $.store.set
Reach L0, draws and remembers. Sees subagent spawns.
Threat model for fable-pin (reach L0, draws and remembers)
Function hooks are early access. Nothing loads without the flag.
For one session:
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude --plugin-dir plugins/fable-pin
To keep it on, add this to ~/.claude/settings.json, which also loads the hooks module of every other installed plugin that ships one:
{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }
Then from this marketplace:
claude plugin marketplace add karanb192/claude-code-mods claude plugin install fable-pin@claude-code-mods
TARGET at the top of hooks/register.ts is the alias or full model id the spawn is rewritten to. An alias resolves the way the Agent tool's model parameter does.
Inside a Claude Code session started in this folder, run /plugin-types. It writes .claude/types/claude-code.d.ts for the installed version; that folder is git-ignored. Then, from this folder:
npx -y -p typescript@5 tsc -p .
The tsconfig here includes hooks and tests, so the hook and both tests are checked against the generated declarations. Nothing else is needed; there is no package.json.
claude plugin test plugins/fable-pin
Two tests, on the official kit from claude-code/testing. The first drives session.start and two agent.spawn calls through the mod: a subagent asking for another model comes out pinned to the target, a fork keeps its model. The second runs /fable-pin off and checks the next spawn is left alone. The inputs are typed AgentSpawnInput and CommandRunInput from claude-code with no casts; the Typecheck section below has the exact command that checks them.
hooks/register.ts 37 lines1import type { Register } from 'claude-code'
2
3const TARGET = 'fable'
4const KEY = 'enabled'
5
6export const register: Register = on => {
7 let enabled = true
8
9 on('session.start', async ($, e, next) => {
10 const r = await next(e)
11 const saved = await $.store.get(KEY)
12 enabled = saved !== false
13 await $.command.register({
14 name: 'fable-pin',
15 description: 'Pin every subagent to the fable model: on, off or status (fable-pin)',
16 argumentHint: '[on | off | status]',
17 immediate: true,
18 })
19 return r
20 })
21
22 on('command.run', { command: 'fable-pin' }, async ($, e) => {
23 const arg = String(e.args ?? '').trim()
24 if (arg === 'on' || arg === 'off') {
25 enabled = arg === 'on'
26 await $.store.set(KEY, enabled)
27 }
28 return { text: enabled ? `fable-pin is on: every subagent runs on ${TARGET}, forks inherit` : 'fable-pin is off: subagents keep the model they asked for' }
29 })
30
31 // Forks always inherit the parent's model, so rewriting theirs would be ignored anyway.
32 on('agent.spawn', async ($, e, next) => {
33 if (!enabled || e.fork || e.model === TARGET) return next(e)
34 return next({ ...e, model: TARGET })
35 })
36}
37