Smart Code Router
Routes a coding task to the optimal model/CLI per task type, using the verified ranking table from research/2026-05-27_coding_arsenal_deep_research.md §3.10. Pure API/CLI routing — does NOT install desktop apps. Every code-generation flow ends with a TestSprite gate recommendation.
When to use
- "Which model should handle this refactor?"
- "Run this task on the best CLI."
- "Compare how Opus vs DeepSeek solve this — side by side."
Quick start (load env first)
bash
bash -c '. /data/.openclaw/secrets/env.sh; python3 skills/smart-code-router/route.py <cmd> ...'
Commands
| Command | Purpose | |---|---| |classify "<task>" | Returns task_type + recommended model + CLI + reason (+ keyword scores). |
| run "<task>" [--auto] | Classify then dispatch to the best CLI. Dry-run by default; --auto executes. |
| compare "<task>" [--models a,b,c] | Run the task on 2-8 models IN PARALLEL (threads, 8 cores KVM8); side-by-side outputs + timing/speedup. |Routing table (hardcoded from research §3.10)
| task_type | model | CLI | trigger | |---|---|---|---| |long_horizon_refactor | claude-opus-4-8 (1M ctx) | claude | refactor / migrate / whole-repo / monorepo |
| general_web | gpt-5.6-sol | codex | react/next/vue, general feature/bug, web |
| android_data_ml | gemini-3.5-flash | gemini-api | android/kotlin/compose, data, ML |
| python_backend_competitive | deepseek-v4 (deepseek-chat) | deepseek-api | fastapi/django, algorithms, competitive |
| test_generation | claude-sonnet-4-6 + TestSprite | claude | tests / pytest / coverage / tdd |
| security_audit | codex-security + Trail of Bits | codex | security / vuln / audit / owasp |Default when no keyword matches: general_web (gpt-5.6-sol).
compare — model keys
claude-opus-4-8, claude-sonnet-4-6, gpt-5.6-sol, gemini-3.1-pro, gemini-3.5-flash, deepseek-chat/deepseek-v4, grok-4.5.
All called via native APIs (Anthropic / OpenAI / Google / DeepSeek base_url / xAI base_url) with keys from env.sh.Examples
bash
Routing decision only
... route.py classify "Refactor the entire monorepo from REST to gRPC"Dispatch to the chosen CLI (dry-run, then --auto to execute)
... route.py run "Implement a React login form with validation" --autoParallel side-by-side comparison (pick the best, then TestSprite)
... route.py compare "Write is_palindrome(s) with 3 doctests" --models claude-opus-4-8,deepseek-chat
TestSprite gate (mandatory)
Every code-generation path prints a TestSprite reminder: rungenerateTestPlanAndCode → runTestsWithAutoFix and do NOT ship until tests pass 100%. Security tasks additionally pair Codex Security with Trail of Bits review.Tested (2026-05-31)
- classify: long-horizon refactor → claude-opus-4-8/claude; android+ML → gemini-3.5-flash/gemini-api; security → codex-security/codex. All correct.
- compare: claude-opus-4-8 vs deepseek-chat ran in parallel — 7.61s wall vs 12.04s sequential (~1.6x speedup), both valid solutions.
- run: dry-run dispatch + TestSprite gate verified.