Skip to content

Claude Model Router Hook

Claude Code hooks that auto-switch model tier based on task complexity

Install

$claude plugin install claude-model-router-hook@claude-model-router-hook

Install command taken from the project's README or registry entry. Always review code before running it.

Claude Model Router Hook

Effort-first model routing for Claude Code. Heuristics-first, opt-in autoswitch.

Install

installer="$(curl -fsSL https://raw.githubusercontent.com/tzachbon/claude-model-router-hook/361031c9381fd6d2b5c47b311b7037015b3c2f6d/install.sh)" && bash -c "$installer"

The wizard asks whether to install globally and star the GitHub repository. Both prompts default to yes. Installation requires Claude Code and Python 3; starring requires an authenticated gh command. Restart Claude Code after installation.

Claude Model Router classifies each prompt by task and effort, then recommends the matching Claude model. It warns by default. Autoswitch is opt-in and only affects new sessions.

What it does

  • Routes prompts with local heuristics and an optional Claude Code fallback.
  • Uses Haiku only for clearly mechanical work; defaults agentic coding to Opus with graduated effort.
  • Routes Agent and Task sub-agents when they spawn. Nested delegation is floored at the implementation target, and an explicit model always wins.
  • Records the requested and resolved model for completed sub-agents, so host-side fallback or allowlist substitutions are visible.
  • Dampens borderline classifications instead of switching tiers on weak evidence.

How it works

Hook Job
UserPromptSubmit Classifies the prompt and warns or writes the next-session model.
PreToolUse Routes Agent and Task spawns.
PostToolUse Logs the model actually used by completed Agent and Task work.
SessionStart Adds the shared task-class rules to each session.

Errors fail open and leave the prompt unchanged. Prefix a prompt with ~ or < to skip routing.

Model Tier Rules

These rules apply to YOU and to every sub-agent you spawn.

Task classes and default targets

Class Target model Effort When to use
mechanical haiku none Git ops, renames, formatting, lint, file moves, version bumps, quick lookups, short imperative tasks.
implementation opus medium Writing or editing code, building features, creating components or APIs, writing tests, standard feature work.
debugging opus high Diagnosing failures, flaky tests, races, regressions, stack traces, bisecting, reproducing bugs.
architecture opus xhigh Architecture decisions, tradeoff analysis, redesigns, deep multi-file analysis, sustained reasoning over large context.
extreme opus max Multi-system migrations, codebase-wide rewrites, long-horizon plans, RFCs and design docs, platform-scale work.
abstain (no routing) - Prompt does not clearly match any class; current model and effort pass through unmodified.

Sub-agent model selection (MANDATORY)

When calling the Agent tool, set the model parameter to match the task class above. Do not default every sub-agent to the highest effort. Match the model and effort to the work: mechanical work goes to haiku, implementation to opus, debugging to opus, deep analysis to opus, and platform-scale work to opus.

Configure

Use ~/.claude/model-router.json globally or .claude/model-router.json in one project. Project settings win.

{
  "version": 2,
  "apply_mode": "warn",
  "allow_fable_autoswitch": false,
  "subagent_enforcement": "on",
  "classifier": { "cli_fallback": true },
  "thresholds": { "effort_warn_distance": 2 }
}

Similar plugs

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Documented system prompts from Anthropic - Claude Fable 5.1, Opus 5.5, Claude Design, Claude Code. OpenAI - ChatGPT GPT-6-Astra, Codex. Google - Gemini 3.8 Flash, 3.1 Pro,…

Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Devin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini…

Explore related