Confirm-first model router for Claude Code.
It automatically runs on UserPromptSubmit and recommends Sonnet 4.6 or Opus based on task complexity.
- Auto-trigger in Claude Code via plugin hook
- Default recommendation:
Sonnet 4.6for daily coding tasks - Recommend
Opusfor architecture-scale, cross-module, high-risk tasks - Require explicit confirmation before applying model switch
- Keep an audit trail in
.claude/router-decisions.jsonl
router/cc-route.py: CLI entrypointrouter/classifier.py: rule + haiku classifierrouter/policies.py: quality-first routing policyrouter/providers.py: Claude CLI adapterrouter/router_service.py: reusable decision API for CLI and hookrouter/interaction.py: confirm-first interaction messagesrouter/hook_bridge.py:UserPromptSubmithook adapterrouter/config.example.yaml: editable config template.claude-plugin/plugin.json: Claude plugin manifesthooks/hooks.json: plugin hook registrationtests/test_classifier.py: classifier teststests/test_policy.py: policy teststests/test_hook_bridge.py: hook bridge tests
- Python 3.10+
- Claude Code CLI available as
claudein PATH - Optional:
pyyamlif you want YAML config parsing from custom files
Install optional dependency:
python3 -m pip install pyyamlDry-run with explanation (no Claude invocation):
python3 router/cc-route.py \
--task "Refactor auth architecture and investigate production outage" \
--mode rule \
--dry-run \
--explainRun through Claude automatically:
python3 router/cc-route.py \
--task "Add tests for one endpoint and update docs" \
--mode rule \
--explainUse Haiku as pre-classifier:
python3 router/cc-route.py \
--task "Migrate user schema and update payment pipeline" \
--mode haiku \
--explain \
--dry-runForce opus when task appears to involve:
- security/privacy-sensitive work
- database/schema migration
- production incidents
- architecture-level or multi-file design/refactors
- unknown root cause debugging
Prefer sonnet when task appears to be:
- focused docs/test updates
- small bug fixes with clear scope
- straightforward endpoint or CRUD adjustments
If uncertain and not clearly high-risk, recommend sonnet-4.6 first and let user confirm upgrade.
Planning/design tasks (e.g. architecture design, implementation plan, roadmap/spec) are forced to recommend opus.
Install this repo as a local Claude plugin:
claude plugins validate .
claude plugins install .Restart Claude Code after install.
When enabled, every prompt triggers the router hook:
- it posts a recommendation message
- it does not force a switch automatically
- you confirm with one of:
/router use sonnet/router use opus/router keep
After confirmation, apply in-session model switch with:
/model sonnet
# or
/model opusAdditional router controls:
/router status
/router help
/router on
/router off
/router mode rule
/router mode haiku
/router why- State file:
.claude/router-state.json - Decision log:
.claude/router-decisions.jsonl
Default config path: router/config.example.yaml.
Key settings:
strategy:sonnet-first|balanced|quality-firstmode:rule|haiku(default:haikufor pre-classification)hook.min_prompt_chars: ignore very short promptshook.prefer_sonnet_for_uncertain: keep daily prompts on Sonnet biashook.force_opus_for_planning: forceopusrecommendation when planning/design intent is detectedhook.recommend_on_every_prompt: iffalse, suppress repeats when recommendation == active modelhook.mode_override: set hook mode without changing globalmode
You can override at runtime:
--mode rule|haiku--default-model--escalation-model--haiku-model--binary
Run tests:
python3 -m unittest discover -s tests -p "test_*.py"Validate plugin manifest:
claude plugins validate .