Skip to content

About

Claude Code plugin: give every subagent a model and effort level sized to its task.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Subagent Router

Right-size every Claude Code subagent. A Claude Code plugin that gives each subagent a model and an effort level that fit its task, instead of letting every subagent inherit your session's settings.

| # | Task                     | Implementer     | Review          | Why                       |
|---|--------------------------|-----------------|-----------------|---------------------------|
| 1 | Rename MAX_ROWS          | haiku / low     | sonnet / medium | one mechanical edit       |
| 2 | rows_to_csv + tests      | sonnet / medium | sonnet / medium | clear spec, 1–2 files     |
| 3 | Wire export endpoint     | sonnet / high   | opus / high     | router, auth, service     |
| 4 | Streaming + tenant check | opus / high     | opus / high     | security-sensitive design |

Reply "go" to start, or change a row (e.g. "4 → opus xhigh").

The idea

Plan-then-execute workflows run a plan by dispatching one subagent per task, plus reviewers and fix rounds. A typical plan mixes very different work: a one-line rename, a small function with tests, a multi-file integration, a security-sensitive design.

By default, every one of those subagents runs on your session's settings:

  • Model. A subagent dispatched without a model inherits the session's model. If you plan on Opus, your rename also runs on Opus.
  • Effort. A subagent dispatched without an effort inherits the session's effort level. The Agent tool's own guidance tells Claude to set effort only when explicitly asked to, so in practice Claude never sets it.

That wastes money and time on easy tasks, and it leaves no headroom for hard ones.

Subagent Router fixes this with four rules:

  1. Decide at plan time. That is when the task is best understood. Each task gets a route line: a model, an effort level and a one-line reason.
  2. Show the routes once. Before the first dispatch, you see a table and can change any row. After you say "go", nothing stops to ask again.
  3. Pass both values on every dispatch. The skill counts as the explicit instruction the Agent tool asks for, so effort gets set.
  4. Escalate one rung at a time. A stuck task moves up a fixed ladder. Effort rises before the model changes, and the top rung hands the decision back to you.

Why subagents and not the main session?

Each model keeps its own prompt cache. Switching the main session's model mid-conversation forces a full, uncached re-read of the whole history, which can cost more than the switch saves. A subagent starts with an empty context, so giving it a different model costs nothing extra. That makes subagents the right place to route.

How it works

1. In the plan, every task gets a route line:

Route: sonnet / high — review: opus / high — touches router, auth middleware and service (5 files)

2. Before execution, Claude posts the route table, as shown above, and waits. If your workflow already asks you something at that point, such as superpowers asking which execution mode you want, the table goes into the same message. You only stop once.

3. On every dispatch, Claude passes both values:

Agent(description: "...", subagent_type: "general-purpose", model: "sonnet", effort: "high", prompt: "...")

4. When a task gets stuck, the next fresh dispatch climbs one rung:

haiku/low → sonnet/medium → sonnet/high → opus/high → opus/xhigh → ask you

Default routing table

Task shape Model Effort
One-step mechanical edit, fully specified haiku low
Clear spec, 1–2 files, with tests sonnet medium
Multi-file wiring or integration; debugging with a known repro sonnet high
Design judgment; security, auth, tenancy, concurrency opus high
Cross-system architecture; long open-ended investigation opus xhigh

Reviews take the row of the riskiest change in their diff. The final whole-branch review runs on opus / high. The router never picks fable unless you ask for it, because Fable may bill usage credits.

Install

claude plugin marketplace add akontadakis/subagent-router
claude plugin install subagent-router@subagent-router

Or try it for one session without installing:

git clone https://github.com/akontadakis/subagent-router
claude --plugin-dir ./subagent-router

Then ask Claude to write or execute a plan with subagents. The skill loads on its own.

Requirements

  • Claude Code v2.1.292 or later for per-subagent effort. On older versions the plugin routes the model only, and the route table says Effort routing is off.
  • Claude Code only. The plugin relies on the Agent tool's model and effort parameters, so it does nothing in other harnesses.

Customize it for your project or team

Don't edit the installed plugin, because updates overwrite it. Add a ## Subagent routing table to your project's CLAUDE.md instead. Its rows replace the defaults, and any task shape it doesn't list falls back to the default table. Commit the file, and everyone on the team routes the same way.

## Subagent routing

| Task shape | model | effort |
|---|---|---|
| Clear spec, 1–2 files, with tests | sonnet | low |
| Database migrations | opus | high |

Works with superpowers and other skills

The plugin stands alone. It works with any workflow that dispatches subagents, and it has no dependencies.

With superpowers:

  • Superpowers owns the process; the router owns the routes. Superpowers already requires a model on every subagent. The router adds effort, the route table and the escalation ladder.
  • Superpowers decides when to escalate. Its fix loop resumes the implementer in rounds 1–3, and a resumed subagent keeps its route. For the fresh implementer in rounds 4–5, the router picks the next rung.
  • Pinned agents stay pinned. If an agent's definition file sets model or effort, the router leaves that value alone unless you change the row.

What overrides the router

Setting Effect
CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 Claude can't pass a model per subagent, so model routing stops.
CLAUDE_CODE_EFFORT_LEVEL Beats every per-subagent effort, so effort routing stops.
A mod's agent.spawn hook that sets a model Replaces the routed model.
Your organization's model allowlist or effort cap Blocked models are substituted, and effort is capped.
Providers where haiku or sonnet resolve to older models An effort level the model doesn't support falls back to the highest level it does.

Limits

  • Subagents only. The router doesn't switch your main session's model.
  • Forks aren't routed. A forked subagent inherits its parent's model and effort.

How it was tested

The skill was written test-first, following superpowers' writing-skills method.

  • Without the skill: test agents running a 5-task plan never set effort, citing the Agent tool's "only when asked" rule. They also started executing without showing the routes.
  • With the skill: every run set both values, showed the table once and waited. That held under "I'm in a hurry, go", alongside superpowers, with a CLAUDE.md routing table, with a pinned agent, and on a Claude Code version without the effort parameter.
  • Real session: an end-to-end run in Claude Code with superpowers installed loaded both skills, stopped once at the route table, and dispatched every subagent on its routed model.

License

MIT

About

Claude Code plugin: give every subagent a model and effort level sized to its task.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors