Switchboard, a Claude Code mod that picks the Claude Code subagent model and tracks its cost
Picks a Haiku, Sonnet or Opus model for each Claude Code subagent that names none, and shows what each one cost.
Permissions
- Reads filesCan read files and list directories on your machine ($.fs.read / list / stat / exists).
- NetworkCan make HTTP requests or talk to MCP servers ($.http.fetch / $.mcp.*).
- Changes the UIDraws into the Claude Code interface: bands, panes, status text, toasts (ui.render / $.ui.*).
- Adds commands/toolsRegisters new slash commands or tools that you or Claude can invoke ($.command.register / $.tool.register).
- tested with
- v2.1.310
- last tested
- requires
- Claude Code ≥ 2.1.287
- surfaces
- above-prompt, pane
- source
- Hamza Zafar (hamzafer) (MIT)
Install inside Claude Code:
/plugin install switchboard --marketplace hamzafer/claude-code-modsWhat does this mod do?
Switchboard is a community mod by Hamza Zafar (hamzafer), part of his claude-code-mods collection. It chooses the Claude Code subagent model for each spawn that does not name one, and keeps a running tally of what every subagent cost. A picker looks at the subagent's type and its short description, then picks one tier from a ladder: Haiku, Sonnet or Opus, or Sonnet, Opus or Fable.
The picker is either OpenAI's Decisions API or Jev, a decision model from TypeSafe that can be called directly or through Vercel AI Gateway. The default picker is off. In that state Switchboard sends nothing anywhere and only tracks cost. If you turn a picker on, the author's description puts each pick at a fraction of a cent.
While subagents run, one line per spawn appears above the prompt, such as ⇄ find auth middleware opus → sonnet jev 91% sure. A line stays for 30 seconds after the subagent finishes and then shows its cost. /route opens a pane that lists each subagent, its pick, what it ran on, and the spend compared with the models originally asked for.
Install
Use any of the methods in the install block; they install straight from the author's own marketplace. Open /config for the plugin to set the mode, picker, model ladder, style and any API keys. The settings are read when the plugin loads, so reload plugins after changing them.
$ install switchboard
Requires Claude Code ≥ 2.1.287
Installs from the author's own marketplace: hamzafer/claude-code-mods
1.One line, inside Claude Code
/plugin install switchboard --marketplace hamzafer/claude-code-modsPaste into a running session (v2.1.275+). Claude Code asks to add the marketplace first.
2.From your shell
claude plugin marketplace add hamzafer/claude-code-mods claude plugin install switchboard@claude-code-modsThen run /reload-plugins in any session that is already open.
3.Try it without installing
git clone https://github.com/hamzafer/claude-code-mods claude --plugin-dir ./claude-code-mods/mods/switchboardLoads the mod for one session only. Nothing is added to your settings.
How it works
Switchboard wraps the agent.spawn hook. It skips forks and teammates, keeps a model the caller named, and otherwise asks the picker. The relevant part of hooks/register.tsx:
const sure = pick.confidence === undefined || pick.confidence >= MIN_CONFIDENCE
const apply = mode === 'auto' && sure && !!pick.tier && asked !== undefined && pick.tier !== tierOf(asked)
const r = await next(apply ? { ...e, model: pick.tier } : e)The request waits at most 4 seconds for the picker. If there is no key, no answer, a failed call or a pick under 50% confidence, the spawn runs unchanged. The request body is built in hooks/route.ts from the subagent type and description only, plus the ladder and the style prompt. After each subagent turn, turn.complete adds its token usage to the log, which keeps the newest 50 subagents and everything still running. Costs come from a price table in the code, dated 2026-09-25.
Customize it
The options are in the plugin's /config:
- Mode:
auto(default) runs each subagent on the picked model;suggestonly shows the pick. - Picker:
off(default),openaiorjev. - Models: the ladder,
haiku-sonnet-opus(default) orsonnet-opus-fable. - Style:
saver(default) asks for the cheapest model that will do the job;qualitypays for the better model on audits, extra reviews, planning and new features. - Keep a named model: on by default.
- API keys: a TypeSafe key, a Vercel AI Gateway key and an OpenAI key, stored as sensitive settings. If a key is empty, the mod falls back to the
TYPESAFE_API_KEY,AI_GATEWAY_API_KEYorOPENAI_API_KEYenvironment variable. - Gateway zero data retention: off by default; it needs a Pro or Enterprise gateway plan.
Permissions & safety
We read every file the plugin can execute before running it: .claude-plugin/plugin.json, hooks/hooks.json, hooks/register.tsx, hooks/route.ts, hooks/bands.ts, the type declarations and the tests. There is no package.json, install script, binary or bundled code, and we found no hidden Unicode, eval or dynamic import. These are the notable findings:
- Network, only when a picker is on. The one
$.http.fetchcall (register.tsx:219) goes tohttps://api.openai.com/v1/decisions,https://api.typesafe.ai/v1/systemoneorhttps://ai-gateway.vercel.sh/v1/evaluate(route.ts:57-59), with your API key as a bearer token. The body holds the subagent type and its short description, never the task prompt. With the picker off, nothing is sent. No telemetry. - Reads environment variables:
OPENAI_API_KEY,TYPESAFE_API_KEY,AI_GATEWAY_API_KEY,HOMEandCLAUDE_CONFIG_DIR. The keys are used only as the bearer token for the picker you chose. - Reads one file:
<config dir>/claude-code-mods/bands.json, the band order shared by the author's other mods (register.tsx:29-33). Switchboard never writes files, runs no processes and starts no background services. Its only timer is a 5-second redraw while the mod is loaded. - Rewrites subagent spawns. In auto mode the
agent.spawnhook can change a subagent's model. It does so only for spawns that name none, and only above 50% confidence.claude plugin validatenotes that this hook has no.catch; the picker call itself catches its own errors and falls back to the unchanged spawn. - Model influence: the mod injects no text into prompts or tool results.
- External requirements: a picker needs a paid API key from OpenAI, TypeSafe or Vercel AI Gateway. Cost tracking and
/routeneed nothing. - License: MIT, with the LICENSE file in the repository root.
claude plugin validate passed with no errors and one non-blocking warning about a missing listing icon. The author's 15 tests passed on Claude Code 2.1.310. They use a mocked engine, so they make no real network calls.
- Reads files
- Can read files and list directories on your machine ($.fs.read / list / stat / exists).
- Network
- Can make HTTP requests or talk to MCP servers ($.http.fetch / $.mcp.*).
- Changes the UI
- Draws into the Claude Code interface: bands, panes, status text, toasts (ui.render / $.ui.*).
- Adds commands/tools
- Registers new slash commands or tools that you or Claude can invoke ($.command.register / $.tool.register).
Compatibility & troubleshooting
Checked with Claude Code 2.1.310 on macOS (validate and tests). If nothing seems to happen:
- The picker is
offby default, so the mod only tracks cost until you chooseopenaiorjevand supply a key. The/routepane header says(no key, nothing changes)when a picker is chosen without one. - A model named by the caller is kept unless you turn off "Keep a named model".
- Subagents that use their own agent definition's model show
own model · try sonnet: a hook cannot see that model, so they get a suggestion and no switch. - A pick below 50% confidence is shown but not applied, with "too unsure to switch" in the reason.
- If
/routeis refused because Claude Code already has a command of that name, the band still works. - Costs show
?until the subagent's first turn completes, and for models missing from the price table.
FAQ
- Does Switchboard send my code or prompts to OpenAI or TypeSafe?
- Not by default, because the picker is off. When you turn it on, each request carries only the subagent's type and its short description label. The task prompt is never included, and a test in the author's suite checks that a secret in the prompt does not appear in the request. A label such as "find auth middleware" does leave your machine, so keep that in mind when you name tasks.
- Do I need an API key?
- Only to use a picker. With the default picker "off" it asks nobody, changes nothing and only tracks what each subagent cost. For OpenAI you need an OpenAI key; for Jev you need a TypeSafe key, or a Vercel AI Gateway key with paid gateway credit. A key in the environment alone never turns a picker on.
- Will it override a model I named for a subagent?
- No. With "Keep a named model" on, which is the default, a spawn that names a model keeps it and the picker is not asked. Forks and teammates are also left alone. Turn the setting off to let the picker route named models too.
- What is the difference between auto and suggest mode?
- In auto mode the picked model replaces the one the subagent would have run on, but only when the picker is at least 50% confident. In suggest mode the pick is only shown above the prompt, such as "opus · try sonnet", and nothing is switched.
- How is the cost calculated, and is it my real bill?
- It is an estimate at API list prices dated 2026-09-25, applied to each subagent's token usage, plus the small fee for the pick itself. It is not a plan charge. The pane shows what was spent and what the same tokens would have cost at the models the spawns asked for.
# Related mods
FeaturedAgent Profiler
Where Claude Code session time goes: model wait, tools, subagents, live in the status line, with OTLP trace export.
- status
- pane
- toast
- Writes files
- Network
- Intercepts tool calls
- Changes the UI
- Adds commands/tools
tested with v2.1.303
FeaturedAgent Radar
One live line above the prompt per running subagent: time, tool count and what it is doing now, plus a /radar pane.
- above-prompt
- pane
- toast
- Intercepts tool calls
- Reads your prompts
- Changes the UI
- Adds commands/tools
tested with v2.1.291
FeaturedContext Meter
Context-window fill, 5-hour and 7-day plan usage and session cost in the status line, plus a warning near the limit.
- status
- toast
- Changes the UI
tested with v2.1.310
More in Context, quota, cost, Timers, todos, standups.