model-routing
Skill708 starsChanged 5 months agoMITView on GitHub
9-tier model routing system with cascading classifier fallback and result auto-evaluation
- Reads credentials
30 other projects use a version of this.
Adopted by
Most recently taken up by
- cveralyon/axel-setuptheir own version, first seen Nov 8, 2026
- naman10parikh/pennytheir own version, first seen Nov 8, 2026
- weedmo/skillstheir own version, first seen Nov 8, 2026
- naman10parikh/wikimemtheir own version, first seen Nov 8, 2026
- fal-ai-community/skillstheir own version, first seen Nov 7, 2026
- ArcReel/ArcReeltheir own version, first seen Nov 1, 2026
Used with
Projects with it also use ecosystem-reference, fractal-delegation and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
naman10parikhSkillecosystem-reference
Quick-access directory of Claude Code ecosystem repos, skills, plugins, MCPs, and patterns. Use when improving the harness.
Also in 5 projects that use this
naman10parikhSkillfractal-delegation
Also in 5 projects that use this
KirchliveSkillskill-routing
Decides which of the installed skills a task needs and loads them before the work starts. This skill should be used at the beginning of any multi-step task — build, fix, refactor, migrate, review, plan, release, research, write, design, video — and again at every phase change, after context compaction, and when work moves into a different part of the codebase. Use it for requests like "let's build X", "fix this bug", "refactor Y", "plan the migration", "review this", and also when the user asks which skill applies, why a skill did not fire, or asks to check what is available.
Also in 5 projects that use this
sublimotionSkillagent-runtime
Launch and manage detached agent runs on EKS via the agent-runner CLI. Use when the user says "launch an agent run", "agent runtime", "agent-runner", "run this spec on the cluster", "check run status", "agent run logs", or "stop a run". Do NOT use for writing the agent-runner code itself (edit the sibling ../agent-runner repo), Terraform of the foundation (use terraform-automation), or GPU serving deployments (use infra-deployer).
Also in 5 projects that use this
GoZippySkillrepo-scout
Also in 5 projects that use this
BenjaminGSkillharness-review
Turn one PR's review comments into harness fixes — classify each cause by the most solid place it can live (codebase, lint, rules, skill), then draft the fixes in a separate PR.
Also in 5 projects that use this
- +6 more from naman10parikh
Other versions30 projects use a version of this.
Word for word · 1
- alinaqi/maggy★ 711100% same
Edited · 0
None found.
Wrote their own version · 29
- ArcReel/ArcReel★ 6.3ksame name
- fal-ai-community/skills★ 265same name
- NoobyGains/godmode★ 118same name
- nahid-sparktales/agent-dispatcher★ 59same name
- echo-of-machines/fable-advisor★ 27same name
- frankxai/agentic-creator-os★ 10same name
- FaisalAlqarni/sp-ecc★ 9same name
- naman10parikh/agentgrid★ 9same name
- naman10parikh/wikimem★ 8same name
- yeaight7/agent-powerups★ 6same name
19 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository75 other files it gives its agents.
- templates/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- templates/CLAUDE.mdCLAUDE.md
- aeo-optimizationSkill
- agentic-developmentSkill
- agent-teamsSkill
- ai-modelsSkill
- android-javaSkill
- android-kotlinSkill
- autonomous-testingSkill
- aws-auroraSkill
- aws-dynamodbSkill
- azure-cosmosdbSkill
- baseSkill
- build-in-publicSkill
- cloudflare-d1Skill
- code-deduplicationSkill
- code-graphSkill
- code-reviewSkill
- codex-reviewSkill
- commit-hygieneSkill
- context-shuntSkill
- council-reviewSkill
- cpg-analysisSkill
- credentialsSkill
- cross-agent-delegationSkill
- database-schemaSkill
- dataforseoSkill
- demo-videoSkill
- existing-repoSkill
- external-model-delegationSkill
- firebaseSkill
- flutterSkill
- gemini-reviewSkill
- icpgSkill
- iterative-developmentSkill
- klaviyoSkill
- llm-patternsSkill
- maggySkill
- medusaSkill
- mnemosSkill
- ms-teams-appsSkill
- nodejs-backendSkill
- playwright-testingSkill
- polyphonySkill
- posthog-analyticsSkill
- project-toolingSkill
- pwa-developmentSkill
- pythonSkill
- react-nativeSkill
- react-webSkill
- reddit-adsSkill
- reddit-apiSkill
- security-auditSkill
- securitySkill
- session-managementSkill
- shopify-appsSkill
- site-architectureSkill
- supabase-nextjsSkill
- supabase-nodeSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 28 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Every user prompt goes through a 9-tier classification pipeline before any AI model processes it.
- Distinctive: line 54
When the hook says "delegate to X", run the matching command and return its output:
- Very specific: line 85
Every ~/bin/ script follows the same pattern:
- Very specific: line 120
Before the hook emits a delegation instruction it checks that the tier's wrapper exists (the resolved flash/pro binary, ~/bin/gemini-api, …
- Distinctive: line 129
When Claude's built-in tools fail, external backends take over:
“Common” is measured: kept by at least 6 in 10 of the 28 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Model Routing System
How Routing Decisions Are Made
Every user prompt goes through a 9-tier classification pipeline before any AI model processes it. The system answers three questions:
- Which model should handle this? — 9-tier cost/complexity classification
- Is the classifier itself working? — Cascading fallback (qwen3 → kimi → deepseek → cache)
- Can we verify the result? — Tool-level fallback + auto-evaluation
The Pipeline
User types prompt
↓
UserPromptSubmit hook fires (~/.claude/hooks/route-task-hook)
↓
Classifier: qwen3 (local, free) classifies into tier
↓ (fails?)
Classifier: kimi (local, free) retries
↓ (fails?)
Classifier: deepseek-flash (~$0.0001) retries
↓ (fails?)
Classifier: cached tier from last success
↓
Hook injects routing decision into Claude's context
↓
Claude delegates to the right model or handles directly9-Tier Routing Table
| Tier | Model | Input (per M) | Output (per M) | Handles |
| 1 | Gemini 2.5 Flash-Lite | $0.10 | $0.40 | Bulk extraction, classification, CIG pipelines |
| 2 | DeepSeek V4 Flash | $0.14 | $0.28 | Simple code, CRUD, test writing, small fixes |
| 3 | DeepSeek V4 Pro | $0.44 | $0.87 | Multi-file features, refactors, debugging (~80% of work) |
| 4 | Gemini 2.5 Flash | $0.15 | $0.60 | Multimodal (images, video, audio), brand analysis |
| 5 | Kimi K2.6 | $0.60 | $2.50 | Code review, commit messages, diff summaries |
| 6 | Gemini 3.1 Pro + Search | $1.25 | $10.00 | Deep research, Google grounding, 2M context |
| 7 | Codex | varies | varies | Bulk generation, code review |
| 8 | Claude Sonnet/Opus | $3-5 | $15-25 | Architecture, security, quality-critical |
Delegation Commands
When the hook says "delegate to X", run the matching command and return its output:
# Tier 1 — Gemini Flash-Lite
~/bin/gemini --flash-lite "prompt"
# Tier 2 — DeepSeek Flash
~/bin/deepseek --flash "prompt"
# Tier 3 — DeepSeek Pro
~/bin/deepseek --pro "prompt"
# Tier 4 — Gemini Flash
~/bin/gemini --flash "prompt"
# Tier 5 — Kimi
~/bin/kimi --quiet -p "prompt"
# Tier 6 — Gemini Pro Search
~/bin/gemini --pro-search "prompt"
# Tier 7 — Codex
codex exec "prompt"
# Tier 8 — Claude
# Handle directly (no delegation)Delegation Script Contract
Every ~/bin/ script follows the same pattern:
- Accepts prompt as argument:
script "what is 2+2" - Model flags:
--flash,--pro,--flash-lite,--pro-search - Quiet mode:
--quiet(where applicable) - Output: writes response to stdout, errors to stderr
- Exit codes: 0 on success, non-zero on failure
Available Scripts
~/bin/
├── qwen3 # Shell: curl to local Ollama API
├── kimi # Shell: execs Kimi CLI binary
├── deepseek # Python: httpx to DeepSeek Anthropic-compat API
├── gemini # Python: httpx to Gemini OpenAI-compat API
├── research # Python: multi-backend research with auto-evaluation
└── route-task # Shell: qwen3-powered task classificationClassifier Fallback Chain
The classifier itself can fail. When it does, cascading fallback kicks in:
| Level | Classifier | Cost | Threshold |
| 1 | qwen3 (Ollama) | $0 | 2s connect, 8s classify |
| 2 | kimi CLI | $0 | Local process |
| 3 | deepseek-flash | ~$0.0001 | API call |
| 4 | Cached tier | $0 | From ~/.claude/routing-cache.json |
The cache (~/.claude/routing-cache.json) saves the last successful tier and timestamp. After compaction, when Ollama may be briefly unreachable, the cache ensures routing continues without dropping to CLAUDE by default.
Missing Wrapper Fallback
Before the hook emits a delegation instruction it checks that the tier's wrapper
exists (the resolved flash/pro binary, ~/bin/gemini-api, ~/bin/gemini-cli,
~/bin/kimi, ~/bin/grok, or codex on PATH). If it is missing, the decision
becomes ROUTING DECISION: CLAUDE (fallback from <tier>) and Claude handles the
task directly, without the PLAN FIRST step. A cached tier the hook no longer
knows is discarded the same way. There is no qwen3 delegation tier any more.
Tool Fallback Protocol
When Claude's built-in tools fail, external backends take over:
| Failed Tool | Fallback 1 | Fallback 2 |
| WebSearch / WebFetch | ~/bin/research "query" | ~/bin/deepseek --pro "query" |
| Read / file access | cat via Bash | — |
| Grep | grep -r via Bash | — |
Research Tool (~/bin/research)
Multi-backend research with auto-evaluation:
- Tries deepseek-flash → deepseek-pro in sequence
- Scores results 0-10 on content quality, structure, length
- Auto-adjusts preferred backend based on evaluation scores
- View stats:
~/bin/research --eval - Score log:
~/.claude/research-eval.jsonl
Maggy Integration
Maggy's model_router.py mirrors the same 9-tier structure in DEFAULT_TIERS. The PiAdapter uses the same delegation scripts for execution. Task type overrides in routing_rules_defaults.py ensure:
research,competitor→ Gemini Pro Search (Google grounding)bulk→ Gemini Flash-Lite (cheapest)security,architecture,planning→ Claude (quality-critical)docs,tests→ DeepSeek Pro (cost-efficient)review→ Claude (security + architecture depth)
Environment
# Required for delegation scripts (in ~/.zshrc)
export DEEPSEEK_API_KEY="sk-..."
export GEMINI_API_KEY="..." # For gemini delegator
export OPENAI_API_KEY="sk-..." # For codex CLI
# Ollama must be running locally for qwen3
ollama serve # or launch at startupObservability
- Routing log:
~/.claude/routing-log.jsonl— every classification with tier, classifier used, tokens saved - Routing cache:
~/.claude/routing-cache.json— last tier for post-compact recovery - Research eval:
~/.claude/research-eval.jsonl— per-query backend scoring - Maggy routing heatmap: Dashboard → Models tab → per-model reward scores
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

