Skill v1.0.1
currentAutomated scan100/100+5 new
name: smart-model-route description: Auto-classify prompt complexity via Haiku (with heuristic fallback) and inject model routing hints for Agent tool calls. Wired as a UserPromptSubmit hook — fires on every prompt, routes low tasks to Haiku, standard to Sonnet, complex to Sonnet with thorough reasoning, and critical (security/arch/migrations) to Opus. Handles model selection, for example choose model by task complexity. triggers:
- smart model routing
- model selection
- route by complexity
- choose model
- auto model
- task complexity
metadata: version: "1.0.1"
Smart Model Route
Classifies each incoming prompt and injects a systemMessage telling the AI which model to pass to Agent tool calls and what reasoning depth to use. Uses Haiku for classification when ANTHROPIC_API_KEY is available; otherwise falls back to keyword heuristics.
How It Works
UserPromptSubmithook fires on every prompt- Sends prompt to
claude-haiku-4-5with a classification system prompt - Returns
low | medium | high | critical - Injects a
[AUTO:haiku]or[AUTO:heuristic]system message for non-medium tasks - Claude uses this to calibrate reasoning depth and
model:parameter on Agent calls
Classification Rules
| Level | Signals | Agent model | |
|---|---|---|---|
| low | Search, grep, read, git status, quick questions, <20 words | claude-haiku-4-5 | |
| medium | Standard coding, bug fixes, typical tasks (default) | claude-haiku-4-5 (env) | |
| high | Implement, refactor, debug, optimize, PR review, >15 words | claude-sonnet-4-6 | |
| critical | Security, OAuth, CVE, arch decisions, prod deploys, migrations | claude-opus-4-7 |
Installation
- Copy
complexity-classifier.shto~/.claude/hooks/ - Make it executable:
chmod +x ~/.claude/hooks/complexity-classifier.sh - Add to
settings.json:
"UserPromptSubmit": [{"matcher": "*","hooks": [{"type": "command","command": "/path/to/hooks/complexity-classifier.sh","timeout": 5}]}]
- To enable Haiku-based classification (vs heuristic fallback):
"env": {"ANTHROPIC_API_KEY": "your-key"}
Or to route through a local LiteLLM / Ollama proxy (set these to your own host + key):
"env": {"ANTHROPIC_API_KEY": "${LITELLM_MASTER_KEY}","ANTHROPIC_BASE_URL": "http://<your-litellm-host>:4000"}
Using in Agent Calls
Once the hook is active, Claude reads the injected hint and applies it:
# For clearly simple tasks (override default)Agent(model="haiku", prompt="search for all TODO comments")# For complex tasks (override default)Agent(model="opus", prompt="design the auth architecture for multi-tenant SaaS")
Session Model Override
For architecture or security sessions, switch the main model:
/model claude-opus-4-7
Switch back when done:
/model claude-sonnet-4-6
Dependencies
anthropicPython SDK (for Haiku classification):pip install anthropic- Heuristic fallback requires no dependencies