Auto model-switching for Claude Code — routes prompts to the right tier to save API tokens
npx claudepluginhub maiha28781-cloud/claude-smart-model-routerAutomatically routes prompts to haiku/sonnet/opus (or any custom tier) based on task complexity. No API calls. Fully configurable via JSON.
Auto model-switching plugin for Claude Code — routes prompts to the right tier to save API tokens.
Every prompt you type is silently classified and compared against your current model:
git commit all changes → recommends haiku (cheap, fast)implement the auth API endpoint → recommends sonnet (default)redesign the entire caching architecture → recommends opus (deep reasoning)No API calls. Zero latency. Fully configurable.
claude plugin marketplace add maiha28781-cloud/smart-model-router
claude plugin install smart-model-router@maiha28781-cloud
Restart Claude Code to activate.
git clone https://github.com/maiha28781-cloud/smart-model-router.git
cd smart-model-router
bash install.sh
Create ~/.claude/smart-model-router.json (global) or .claude/smart-model-router.json (project-level, overrides global):
{
"action": "warn",
"tiers": [
{
"name": "haiku",
"models": ["haiku"],
"switch_to": "haiku",
"priority": 1,
"description": "Simple mechanical tasks",
"max_word_count": 60,
"patterns": ["\\bgit\\s+(status|log|diff)\\b"]
},
{
"name": "sonnet",
"models": ["sonnet"],
"switch_to": "sonnet",
"priority": 2,
"description": "Standard implementation",
"is_default": true,
"patterns": ["\\bimplement\\b", "\\bfix\\b"]
},
{
"name": "opus",
"models": ["opus"],
"switch_to": "opus",
"priority": 3,
"description": "Deep analysis",
"force_min_word_count": 200,
"keywords": ["architecture", "analyze", "strategy"]
}
]
}
{
"name": "my-model",
"models": ["my-model-id"],
"switch_to": "my-model-id",
"priority": 4,
"description": "My specialized model",
"keywords": ["ultra complex", "full codebase audit"],
"patterns": []
}
{
"opus": {
"mode": "extend",
"keywords": ["my-custom-signal"],
"remove_keywords": ["rethink"]
},
"haiku": {
"mode": "replace",
"patterns": ["\\bgit status\\b"]
}
}
mode: extend(default) — adds to built-in keywords/patterns, supportsremove_keywords/remove_patterns
mode: replace— discards built-ins entirely, uses only your list
| Field | Type | Default | Description |
|---|---|---|---|
action | warn | autoswitch | warn | warn = recommend only; autoswitch = change settings.json automatically |
default_model | string | sonnet | Assumed model when settings.json has no model field |
tiers | array | see defaults | List of model tiers |
| Field | Type | Description |
|---|---|---|
name | string | Display name |
models | string[] | Substrings matched against current model |
switch_to | string | Value written to settings.json on autoswitch |
priority | int | Tier weight (lower = lighter). Must be unique. |
mode | extend | replace | Whether to extend or replace default keywords/patterns |
keywords | string[] | Case-insensitive keywords matched against prompt |
remove_keywords | string[] | Remove specific defaults (extend mode only) |
patterns | string[] | Python regex patterns matched against prompt |
remove_patterns | string[] | Remove specific default patterns (extend mode only) |
max_word_count | int | Only match if prompt is shorter than this |
min_word_count | int | Only match if prompt is longer than this |
force_min_word_count | int | Force this tier if prompt exceeds N words |
force_question_word_count | int | Force this tier if prompt is a long question |
Prefix any prompt with ~ to skip classification entirely:
~ do this with whatever model i'm on
All routing decisions are logged as structured NDJSON at ~/.claude/logs/smart-model-router.ndjson.
# All-time summary
bash ~/.claude/plugins/cache/maiha28781-cloud/smart-model-router/*/plugins/smart-model-router/hooks/analytics.sh
# Last 7 days
bash analytics.sh --days 7
# Machine-readable JSON
bash analytics.sh --json
Example output:
==================================================
SMART MODEL ROUTER ANALYTICS
==================================================
Total prompts classified : 142
Blocked (wrong model) : 38 (26.8%)
Allowed (correct model) : 97 (68.3%)
Overridden (~) : 7 (4.9%)
Recommendation breakdown:
sonnet 82 (57.7%)
haiku 41 (28.9%)
opus 19 (13.4%)
Top mismatch flows (blocked):
sonnet → haiku 22x
sonnet → opus 12x
opus → sonnet 4x
==================================================
Development marketplace for Superpowers core skills library
Harness-native ECC skills, hooks, rules, MCP conventions, and operator workflows
Open Design — local-first design app exposed to coding agents over MCP. Install once with your agent's plugin command and projects/files/skills are reachable through stdio.