[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6NWFV3G0BNKKBMQJVRFNBAJ":3,"skill-same:01M6NWFV3G0BNKKBMQJVRFNBAJ":63},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":36,"linkOnly":37,"markdownContent":38,"markdownBody":39,"frontMatter":40,"refName":41,"commitSha":42,"skillDirectory":43,"forksCount":14,"repositoryHtmlUrl":44,"repositoryHomepageUrl":6,"ownerHtmlUrl":45,"ownerBlogUrl":46,"ownerDescription":47,"updatedAt":48,"install":49,"resources":62},"01M6NWFV3G0BNKKBMQJVRFNBAJ","smart-model-routing",null,"Dynamic model selection based on task complexity scoring. Replaces static model mappings with a weighted signal system that picks Opus, Sonnet, or Haiku-class speed per task. Works with agent-assignment-matrix.md.","rubicanjr\u002FFinCognis","rubicanjr","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F234912519?v=4","01M6NT156NND8J474G34SB3923","Rubi","01M6NT15B70RWXE1N3YV0BZY8A",0,"MIT","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fsmart-model-routing\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],"routing","smart model routing","model","system","haiku","complexity","selection","task","scoring","speed","with","sonnet","opus","matrix","static","signal","model selection","2026-11-10 10:12:30",false,"---\nname: smart-model-routing\ndescription: Dynamic model selection based on task complexity scoring. Replaces static model mappings with a weighted signal system that picks Opus, Sonnet, or Haiku-class speed per task. Works with agent-assignment-matrix.md.\n---\n\n# Smart Model Routing\n\nDynamic model selection based on task complexity. Never use a sledgehammer where a scalpel will do — and never use a scalpel where you need a sledgehammer.\n\n## Core Philosophy\n\nStatic model assignments (\"always use Sonnet for code\") waste money on trivial tasks and produce poor results on complex ones. This skill scores every task across three signal categories and routes it to the appropriate model tier automatically.\n\n**Default rule: inherit parent model.** Only override when the score clearly warrants a different tier. Never specify a model without a scoring reason.\n\n---\n\n## Signal Categories\n\nThree weighted categories are evaluated. Their scores combine into a single complexity score (0-20 typical range, can exceed).\n\n### Category 1: Lexical Signals (weight: 0.3)\n\nAnalyze the raw text of the request.\n\n#### Architecture Keywords (+3 each)\nTrigger words that indicate high-stakes design work:\n- \"redesign\", \"overhaul\", \"new system\", \"migrate\", \"refactor entire\", \"rewrite\"\n- \"architecture\", \"from scratch\", \"greenfield\", \"new service\", \"platform\"\n\nExample: \"Redesign the authentication system\" → +3\n\n#### Risk Keywords (+2 each)\nDomains where mistakes are expensive or irreversible:\n- \"production\", \"security\", \"auth\", \"authentication\", \"authorization\"\n- \"payment\", \"billing\", \"database migration\", \"data loss\", \"rollback\"\n- \"GDPR\", \"compliance\", \"PII\", \"encryption\", \"secrets\", \"credentials\"\n\nExample: \"Update the payment processing logic\" → +2\n\n#### Simple Keywords (-2 each)\nSignals the task is mechanical and bounded:\n- \"fix typo\", \"update text\", \"rename\", \"add comment\", \"change color\"\n- \"update label\", \"fix spacing\", \"update copy\", \"minor tweak\"\n\nExample: \"Fix the typo in the header\" → -2\n\n#### Question Depth (+1 per layer of constraint)\nCount nested conditions, multiple constraints, OR clauses:\n- Single direct question → 0\n- \"...but also consider X\" → +1\n- \"...and it must handle Y, while also supporting Z\" → +2\n\n#### Word Count Thresholds\n- Under 20 words → -1 (terse request, likely simple)\n- Over 200 words → +1 (detailed spec, likely complex)\n- Over 500 words → +2 (full brief, high complexity expected)\n\n---\n\n### Category 2: Structural Signals (weight: 0.4)\n\nAnalyze the task structure, not just the words.\n\n#### Subtask Count\nHow many discrete steps or deliverables?\n- 1 subtask → 0\n- 2-3 subtasks → +1\n- 4-6 subtasks → +2\n- 7 or more → +3\n\nExample: \"Build an endpoint, write tests, add validation, update docs, add migration, hook up auth, notify the frontend team\" → +3\n\n#### Cross-File Dependencies\nHow many files will be touched?\n- 1 file → 0\n- 2-3 files → +1\n- 4 or more files → +2\n\nUse `tldr impact \u003Cfunction>` or `tldr calls .` to estimate before scoring.\n\n#### Impact Scope\nWhere in the system does this change land?\n- Function-level change → 0\n- Module or feature boundary → +1\n- System-wide, cross-cutting concern → +3\n\nExamples:\n- \"Update the formatDate helper\" → 0\n- \"Refactor the notification module\" → +1\n- \"Change how auth tokens are validated across all routes\" → +3\n\n#### Reversibility\nCan this be easily undone?\n- Easily reversible (toggle a flag, revert a file) → 0\n- Hard to undo (DB migration, data transform, breaking API change) → +2\n\n#### Test Requirement\nWhat level of test coverage is needed?\n- No new tests required → 0\n- Extend existing tests → +1\n- Write a new test suite from scratch → +2\n\n---\n\n### Category 3: Context Signals (weight: 0.3)\n\nThe situation around the request, not just the request itself.\n\n#### Previous Errors in Session\nHas this task or related area already failed once?\n- 0 errors so far → 0\n- 1-2 prior failures on this task → +1\n- 3 or more failures → +2\n\nRationale: repeated failures indicate the problem is genuinely hard. Escalate.\n\n#### Agent Chain Depth\nIs this a top-level user request or the 3rd handoff in a chain?\n- Direct request → 0\n- 2 agents deep → +1\n- 3 or more agents deep → +2\n\nDeep chains accumulate complexity. Each layer adds ambiguity risk.\n\n#### Codebase Familiarity\nIs this a well-trodden path or new territory?\n- Known patterns, familiar framework → 0\n- New-to-session framework, unfamiliar library → +2\n- Undocumented legacy code, no tests exist → +3\n\n---\n\n## Tier Thresholds\n\nAfter computing the weighted sum:\n\n```\nraw_score = (lexical_raw * 0.3) + (structural_raw * 0.4) + (context_raw * 0.3)\n```\n\n| Score | Tier | Model | Use Case |\n|-------|------|-------|----------|\n| >= 8 | HIGH | Opus | System design, security, complex debugging, migration planning |\n| >= 4 | MEDIUM | Sonnet | Standard development, feature work, code review |\n| \u003C 4 | LOW | Haiku-class speed | Typo fixes, label changes, simple renames, formatting |\n\n---\n\n## Confidence Calculation\n\nScore proximity to a threshold boundary determines confidence.\n\n| Distance from nearest threshold | Confidence | Action |\n|----------------------------------|-----------|--------|\n| Score within 1 point of boundary | LOW | Escalate to higher tier |\n| Score 2+ points from boundary | HIGH | Use computed tier |\n\n### Escalation on Low Confidence\n\nWhen confidence is LOW, always round up to the higher tier. A false negative (using a weak model on a hard task) is far more costly than a false positive (using a strong model on an easy task).\n\nExample:\n- Score = 7.2, threshold for HIGH = 8 → Distance = 0.8 → LOW confidence → use Opus anyway\n- Score = 5.8, threshold for MEDIUM = 4 → Distance = 1.8 → LOW confidence → use Sonnet (already in medium, no escalation needed)\n- Score = 3.1, threshold for LOW = 4 → Distance = 0.9 → LOW confidence → use Sonnet (escalate from Haiku)\n\n---\n\n## Hard Rules (Override Score)\n\nThese override the scoring system completely. No exceptions.\n\n### Never Use Haiku For:\n- Security reviews of any kind\n- Authentication or authorization logic\n- Architectural or design decisions\n- Any task touching payment, billing, or financial data\n- Multi-file refactoring (4+ files)\n- Database migrations\n- Unfamiliar codebases without existing tests\n\n### Always Use Opus For:\n- System design from scratch\n- Complex multi-step debugging with no clear root cause\n- Migration planning (major version upgrades, framework migrations)\n- Security audit of critical paths\n- When 2+ prior attempts have failed on the same task\n- Agent chains 3+ deep on a non-trivial task\n\n---\n\n## Application Rules\n\n### For Agent Spawns\nWhen spawning sub-agents, include model selection in the spawn parameters only when the score warrants it. Omit `model` entirely when the task should inherit.\n\n```typescript\n\u002F\u002F CORRECT: score = 9 (HIGH) → specify Opus\nTask({\n  prompt: \"Design the new event sourcing architecture...\",\n  model: \"claude-opus-4-5\"\n})\n\n\u002F\u002F CORRECT: score = 5 (MEDIUM) → inherit, omit model\nTask({\n  prompt: \"Add input validation to the create endpoint...\"\n  \u002F\u002F no model param\n})\n\n\u002F\u002F WRONG: always specifying model\nTask({\n  prompt: \"Fix the typo in the README\",\n  model: \"claude-opus-4-5\"  \u002F\u002F wasteful\n})\n```\n\n### For Inline Decisions\nWhen deciding which model to use for your own reasoning:\n- If score >= 8 and you are not already on Opus: note the gap and do your best\n- If score \u003C 4: do not overthink, execute directly\n\n---\n\n## Scoring Examples\n\n### Example 1: Trivial Fix\nRequest: \"Change the button text from 'Submit' to 'Save'\"\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: simple keyword (\"change\") | -2 | |\n| Lexical: word count (7 words) | -1 | |\n| Structural: 1 file, 1 subtask, function-level, reversible, no tests | 0 | |\n| Context: no errors, direct request, familiar codebase | 0 | |\n| Weighted total | | 0.9 (LOW) |\n\nTier: LOW. Model: Haiku-class. Confidence: HIGH.\n\n---\n\n### Example 2: New Feature Endpoint\nRequest: \"Add a POST \u002Fapi\u002Forders endpoint with Zod validation, rate limiting, auth middleware, and write integration tests\"\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: no arch keywords, no risk keywords | 0 | |\n| Lexical: word count ~20 | 0 | |\n| Structural: 4 subtasks (+2), 3-4 files (+1), module-level (+1), reversible (0), new tests (+2) | 6 | |\n| Context: no prior errors, direct, familiar | 0 | |\n| Weighted total | | (0 * 0.3) + (6 * 0.4) + (0 * 0.3) = 2.4 → LOW |\n\nWait — re-check: \"auth middleware\" is a risk keyword (+2 lexical). Update:\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: risk keyword \"auth\" (+2) | 2 | |\n| Structural: 6 signals total | 6 | |\n| Context: 0 | 0 | |\n| Weighted total | | (2 * 0.3) + (6 * 0.4) + (0 * 0.3) = 3.0 → LOW, but hard rule: auth → override to MEDIUM |\n\nTier: MEDIUM. Model: Sonnet. Hard rule override applied.\n\n---\n\n### Example 3: Security Audit\nRequest: \"Audit the authentication flow. We've had two incidents this week where tokens weren't being validated correctly in production. Find root cause and fix.\"\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: risk keywords \"authentication\", \"tokens\", \"production\" (+2 +2 +2) | 6 | |\n| Lexical: question depth (find root cause AND fix, two constraints) | +2 | |\n| Lexical: word count 36 | 0 | |\n| Structural: unknown subtask count (investigation = open-ended) → treat as 4+ (+2), 3+ files (+2), system-wide (+3), hard to reverse (+2) | 9 | |\n| Context: 2 prior production incidents = treat as 2 errors (+1), direct request (0), known codebase (0) | 1 | |\n| Weighted total | | (8 * 0.3) + (9 * 0.4) + (1 * 0.3) = 2.4 + 3.6 + 0.3 = 6.3 → MEDIUM |\n\nBut: hard rule \"security review of any kind\" AND \"2+ prior failures\" → override to HIGH.\n\nTier: HIGH. Model: Opus. Hard rule override applied (security + repeated failures).\n\n---\n\n### Example 4: Database Migration\nRequest: \"Migrate the users table to add a composite index on (email, tenant_id), backfill existing rows, and update all queries that touch this table\"\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: risk keywords \"database migration\" (+2) | 2 | |\n| Lexical: word count 30 | 0 | |\n| Structural: 3 subtasks (+1), 4+ files (+2), system-wide (+3), irreversible (+2), new tests for migration (+2) | 10 | |\n| Context: no errors yet, direct, familiar | 0 | |\n| Weighted total | | (2 * 0.3) + (10 * 0.4) + (0 * 0.3) = 0.6 + 4.0 + 0 = 4.6 → MEDIUM |\n\nBut: hard rule \"database migration\" → override to HIGH.\n\nTier: HIGH. Model: Opus. Score near boundary + hard rule.\n\n---\n\n## Decision Log Format\n\nEvery routing decision must be logged:\n\n```\nROUTING DECISION\n  TASK: [brief description]\n  SCORE: [weighted total] (lexical=[X], structural=[Y], context=[Z])\n  TIER: [LOW|MEDIUM|HIGH]\n  CONFIDENCE: [HIGH|LOW]\n  HARD_RULE: [rule name if override applied, else \"none\"]\n  MODEL: [selected model]\n  REASON: [1-sentence justification]\n```\n\nExample:\n```\nROUTING DECISION\n  TASK: Security audit of auth token validation\n  SCORE: 6.3 (lexical=8, structural=9, context=1)\n  TIER: HIGH (override from MEDIUM)\n  CONFIDENCE: HIGH\n  HARD_RULE: security-review + repeated-failures\n  MODEL: claude-opus-4-5\n  REASON: Active production security incident with two prior failures; hard rule override applied\n```\n\n---\n\n## Integration with vibecosystem\n\n### Agent Assignment Matrix\nThis skill overrides the default model assignments in `agent-assignment-matrix.md` when a scoring reason exists. The matrix defines WHICH agent handles a task; this skill defines WHICH MODEL that agent uses.\n\nPriority order:\n1. Hard rules (override everything)\n2. Confidence-based escalation\n3. Computed tier\n4. Agent matrix default\n5. Parent model inheritance (fallback)\n\n### QA Loop Integration\nWhen a task enters its second or third retry in the `qa-loop.md` Dev-QA cycle:\n- Add +1 to context signals for each prior failure\n- Re-score the task\n- If tier escalates, upgrade model for the retry\n\nThis prevents the failure loop of using the same weak model repeatedly on a hard task.\n\n### Memory Recall\nBefore scoring, check if a similar task has been attempted before:\n```bash\ncd ~\u002F.claude && PYTHONPATH=scripts python3 scripts\u002Fcore\u002Frecall_learnings.py \\\n  --query \"model routing [task description]\" --text-only\n```\n\nIf a prior attempt used a different tier and succeeded or failed, factor that into the context signal score.\n\n---\n\n## Anti-patterns\n\n| Anti-pattern | Why It Fails | Correct Behavior |\n|---|---|---|\n| Always specifying Opus \"to be safe\" | Slow, expensive, no learning signal | Score the task, use the right tier |\n| Always inheriting parent model | Complex sub-tasks get wrong model | Score independently, override when needed |\n| Using model as a retry strategy | Same model will fail the same way | If score warrants higher tier, upgrade |\n| Ignoring hard rules | Security bugs, data loss | Hard rules exist because the cost of failure is asymmetric |\n| Scoring once per session | Context changes, errors accumulate | Re-score on retry, re-score when context shifts |\n\n---\n\n## Checklist\n\nBefore routing any agent spawn or model selection decision:\n\n- [ ] Evaluated all three signal categories\n- [ ] Applied weights (0.3 \u002F 0.4 \u002F 0.3)\n- [ ] Checked distance from threshold boundary\n- [ ] Checked all hard rules\n- [ ] Logged the decision (TASK, SCORE, TIER, CONFIDENCE, HARD_RULE, MODEL, REASON)\n- [ ] Omitted `model` param if inheriting from parent\n\n**Remember**: The goal is the right model for the job. Not the most expensive one. Not the default one. The right one.\n","# Smart Model Routing\n\nDynamic model selection based on task complexity. Never use a sledgehammer where a scalpel will do — and never use a scalpel where you need a sledgehammer.\n\n## Core Philosophy\n\nStatic model assignments (\"always use Sonnet for code\") waste money on trivial tasks and produce poor results on complex ones. This skill scores every task across three signal categories and routes it to the appropriate model tier automatically.\n\n**Default rule: inherit parent model.** Only override when the score clearly warrants a different tier. Never specify a model without a scoring reason.\n\n---\n\n## Signal Categories\n\nThree weighted categories are evaluated. Their scores combine into a single complexity score (0-20 typical range, can exceed).\n\n### Category 1: Lexical Signals (weight: 0.3)\n\nAnalyze the raw text of the request.\n\n#### Architecture Keywords (+3 each)\nTrigger words that indicate high-stakes design work:\n- \"redesign\", \"overhaul\", \"new system\", \"migrate\", \"refactor entire\", \"rewrite\"\n- \"architecture\", \"from scratch\", \"greenfield\", \"new service\", \"platform\"\n\nExample: \"Redesign the authentication system\" → +3\n\n#### Risk Keywords (+2 each)\nDomains where mistakes are expensive or irreversible:\n- \"production\", \"security\", \"auth\", \"authentication\", \"authorization\"\n- \"payment\", \"billing\", \"database migration\", \"data loss\", \"rollback\"\n- \"GDPR\", \"compliance\", \"PII\", \"encryption\", \"secrets\", \"credentials\"\n\nExample: \"Update the payment processing logic\" → +2\n\n#### Simple Keywords (-2 each)\nSignals the task is mechanical and bounded:\n- \"fix typo\", \"update text\", \"rename\", \"add comment\", \"change color\"\n- \"update label\", \"fix spacing\", \"update copy\", \"minor tweak\"\n\nExample: \"Fix the typo in the header\" → -2\n\n#### Question Depth (+1 per layer of constraint)\nCount nested conditions, multiple constraints, OR clauses:\n- Single direct question → 0\n- \"...but also consider X\" → +1\n- \"...and it must handle Y, while also supporting Z\" → +2\n\n#### Word Count Thresholds\n- Under 20 words → -1 (terse request, likely simple)\n- Over 200 words → +1 (detailed spec, likely complex)\n- Over 500 words → +2 (full brief, high complexity expected)\n\n---\n\n### Category 2: Structural Signals (weight: 0.4)\n\nAnalyze the task structure, not just the words.\n\n#### Subtask Count\nHow many discrete steps or deliverables?\n- 1 subtask → 0\n- 2-3 subtasks → +1\n- 4-6 subtasks → +2\n- 7 or more → +3\n\nExample: \"Build an endpoint, write tests, add validation, update docs, add migration, hook up auth, notify the frontend team\" → +3\n\n#### Cross-File Dependencies\nHow many files will be touched?\n- 1 file → 0\n- 2-3 files → +1\n- 4 or more files → +2\n\nUse `tldr impact \u003Cfunction>` or `tldr calls .` to estimate before scoring.\n\n#### Impact Scope\nWhere in the system does this change land?\n- Function-level change → 0\n- Module or feature boundary → +1\n- System-wide, cross-cutting concern → +3\n\nExamples:\n- \"Update the formatDate helper\" → 0\n- \"Refactor the notification module\" → +1\n- \"Change how auth tokens are validated across all routes\" → +3\n\n#### Reversibility\nCan this be easily undone?\n- Easily reversible (toggle a flag, revert a file) → 0\n- Hard to undo (DB migration, data transform, breaking API change) → +2\n\n#### Test Requirement\nWhat level of test coverage is needed?\n- No new tests required → 0\n- Extend existing tests → +1\n- Write a new test suite from scratch → +2\n\n---\n\n### Category 3: Context Signals (weight: 0.3)\n\nThe situation around the request, not just the request itself.\n\n#### Previous Errors in Session\nHas this task or related area already failed once?\n- 0 errors so far → 0\n- 1-2 prior failures on this task → +1\n- 3 or more failures → +2\n\nRationale: repeated failures indicate the problem is genuinely hard. Escalate.\n\n#### Agent Chain Depth\nIs this a top-level user request or the 3rd handoff in a chain?\n- Direct request → 0\n- 2 agents deep → +1\n- 3 or more agents deep → +2\n\nDeep chains accumulate complexity. Each layer adds ambiguity risk.\n\n#### Codebase Familiarity\nIs this a well-trodden path or new territory?\n- Known patterns, familiar framework → 0\n- New-to-session framework, unfamiliar library → +2\n- Undocumented legacy code, no tests exist → +3\n\n---\n\n## Tier Thresholds\n\nAfter computing the weighted sum:\n\n```\nraw_score = (lexical_raw * 0.3) + (structural_raw * 0.4) + (context_raw * 0.3)\n```\n\n| Score | Tier | Model | Use Case |\n|-------|------|-------|----------|\n| >= 8 | HIGH | Opus | System design, security, complex debugging, migration planning |\n| >= 4 | MEDIUM | Sonnet | Standard development, feature work, code review |\n| \u003C 4 | LOW | Haiku-class speed | Typo fixes, label changes, simple renames, formatting |\n\n---\n\n## Confidence Calculation\n\nScore proximity to a threshold boundary determines confidence.\n\n| Distance from nearest threshold | Confidence | Action |\n|----------------------------------|-----------|--------|\n| Score within 1 point of boundary | LOW | Escalate to higher tier |\n| Score 2+ points from boundary | HIGH | Use computed tier |\n\n### Escalation on Low Confidence\n\nWhen confidence is LOW, always round up to the higher tier. A false negative (using a weak model on a hard task) is far more costly than a false positive (using a strong model on an easy task).\n\nExample:\n- Score = 7.2, threshold for HIGH = 8 → Distance = 0.8 → LOW confidence → use Opus anyway\n- Score = 5.8, threshold for MEDIUM = 4 → Distance = 1.8 → LOW confidence → use Sonnet (already in medium, no escalation needed)\n- Score = 3.1, threshold for LOW = 4 → Distance = 0.9 → LOW confidence → use Sonnet (escalate from Haiku)\n\n---\n\n## Hard Rules (Override Score)\n\nThese override the scoring system completely. No exceptions.\n\n### Never Use Haiku For:\n- Security reviews of any kind\n- Authentication or authorization logic\n- Architectural or design decisions\n- Any task touching payment, billing, or financial data\n- Multi-file refactoring (4+ files)\n- Database migrations\n- Unfamiliar codebases without existing tests\n\n### Always Use Opus For:\n- System design from scratch\n- Complex multi-step debugging with no clear root cause\n- Migration planning (major version upgrades, framework migrations)\n- Security audit of critical paths\n- When 2+ prior attempts have failed on the same task\n- Agent chains 3+ deep on a non-trivial task\n\n---\n\n## Application Rules\n\n### For Agent Spawns\nWhen spawning sub-agents, include model selection in the spawn parameters only when the score warrants it. Omit `model` entirely when the task should inherit.\n\n```typescript\n\u002F\u002F CORRECT: score = 9 (HIGH) → specify Opus\nTask({\n  prompt: \"Design the new event sourcing architecture...\",\n  model: \"claude-opus-4-5\"\n})\n\n\u002F\u002F CORRECT: score = 5 (MEDIUM) → inherit, omit model\nTask({\n  prompt: \"Add input validation to the create endpoint...\"\n  \u002F\u002F no model param\n})\n\n\u002F\u002F WRONG: always specifying model\nTask({\n  prompt: \"Fix the typo in the README\",\n  model: \"claude-opus-4-5\"  \u002F\u002F wasteful\n})\n```\n\n### For Inline Decisions\nWhen deciding which model to use for your own reasoning:\n- If score >= 8 and you are not already on Opus: note the gap and do your best\n- If score \u003C 4: do not overthink, execute directly\n\n---\n\n## Scoring Examples\n\n### Example 1: Trivial Fix\nRequest: \"Change the button text from 'Submit' to 'Save'\"\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: simple keyword (\"change\") | -2 | |\n| Lexical: word count (7 words) | -1 | |\n| Structural: 1 file, 1 subtask, function-level, reversible, no tests | 0 | |\n| Context: no errors, direct request, familiar codebase | 0 | |\n| Weighted total | | 0.9 (LOW) |\n\nTier: LOW. Model: Haiku-class. Confidence: HIGH.\n\n---\n\n### Example 2: New Feature Endpoint\nRequest: \"Add a POST \u002Fapi\u002Forders endpoint with Zod validation, rate limiting, auth middleware, and write integration tests\"\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: no arch keywords, no risk keywords | 0 | |\n| Lexical: word count ~20 | 0 | |\n| Structural: 4 subtasks (+2), 3-4 files (+1), module-level (+1), reversible (0), new tests (+2) | 6 | |\n| Context: no prior errors, direct, familiar | 0 | |\n| Weighted total | | (0 * 0.3) + (6 * 0.4) + (0 * 0.3) = 2.4 → LOW |\n\nWait — re-check: \"auth middleware\" is a risk keyword (+2 lexical). Update:\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: risk keyword \"auth\" (+2) | 2 | |\n| Structural: 6 signals total | 6 | |\n| Context: 0 | 0 | |\n| Weighted total | | (2 * 0.3) + (6 * 0.4) + (0 * 0.3) = 3.0 → LOW, but hard rule: auth → override to MEDIUM |\n\nTier: MEDIUM. Model: Sonnet. Hard rule override applied.\n\n---\n\n### Example 3: Security Audit\nRequest: \"Audit the authentication flow. We've had two incidents this week where tokens weren't being validated correctly in production. Find root cause and fix.\"\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: risk keywords \"authentication\", \"tokens\", \"production\" (+2 +2 +2) | 6 | |\n| Lexical: question depth (find root cause AND fix, two constraints) | +2 | |\n| Lexical: word count 36 | 0 | |\n| Structural: unknown subtask count (investigation = open-ended) → treat as 4+ (+2), 3+ files (+2), system-wide (+3), hard to reverse (+2) | 9 | |\n| Context: 2 prior production incidents = treat as 2 errors (+1), direct request (0), known codebase (0) | 1 | |\n| Weighted total | | (8 * 0.3) + (9 * 0.4) + (1 * 0.3) = 2.4 + 3.6 + 0.3 = 6.3 → MEDIUM |\n\nBut: hard rule \"security review of any kind\" AND \"2+ prior failures\" → override to HIGH.\n\nTier: HIGH. Model: Opus. Hard rule override applied (security + repeated failures).\n\n---\n\n### Example 4: Database Migration\nRequest: \"Migrate the users table to add a composite index on (email, tenant_id), backfill existing rows, and update all queries that touch this table\"\n\n| Signal | Value | Score |\n|--------|-------|-------|\n| Lexical: risk keywords \"database migration\" (+2) | 2 | |\n| Lexical: word count 30 | 0 | |\n| Structural: 3 subtasks (+1), 4+ files (+2), system-wide (+3), irreversible (+2), new tests for migration (+2) | 10 | |\n| Context: no errors yet, direct, familiar | 0 | |\n| Weighted total | | (2 * 0.3) + (10 * 0.4) + (0 * 0.3) = 0.6 + 4.0 + 0 = 4.6 → MEDIUM |\n\nBut: hard rule \"database migration\" → override to HIGH.\n\nTier: HIGH. Model: Opus. Score near boundary + hard rule.\n\n---\n\n## Decision Log Format\n\nEvery routing decision must be logged:\n\n```\nROUTING DECISION\n  TASK: [brief description]\n  SCORE: [weighted total] (lexical=[X], structural=[Y], context=[Z])\n  TIER: [LOW|MEDIUM|HIGH]\n  CONFIDENCE: [HIGH|LOW]\n  HARD_RULE: [rule name if override applied, else \"none\"]\n  MODEL: [selected model]\n  REASON: [1-sentence justification]\n```\n\nExample:\n```\nROUTING DECISION\n  TASK: Security audit of auth token validation\n  SCORE: 6.3 (lexical=8, structural=9, context=1)\n  TIER: HIGH (override from MEDIUM)\n  CONFIDENCE: HIGH\n  HARD_RULE: security-review + repeated-failures\n  MODEL: claude-opus-4-5\n  REASON: Active production security incident with two prior failures; hard rule override applied\n```\n\n---\n\n## Integration with vibecosystem\n\n### Agent Assignment Matrix\nThis skill overrides the default model assignments in `agent-assignment-matrix.md` when a scoring reason exists. The matrix defines WHICH agent handles a task; this skill defines WHICH MODEL that agent uses.\n\nPriority order:\n1. Hard rules (override everything)\n2. Confidence-based escalation\n3. Computed tier\n4. Agent matrix default\n5. Parent model inheritance (fallback)\n\n### QA Loop Integration\nWhen a task enters its second or third retry in the `qa-loop.md` Dev-QA cycle:\n- Add +1 to context signals for each prior failure\n- Re-score the task\n- If tier escalates, upgrade model for the retry\n\nThis prevents the failure loop of using the same weak model repeatedly on a hard task.\n\n### Memory Recall\nBefore scoring, check if a similar task has been attempted before:\n```bash\ncd ~\u002F.claude && PYTHONPATH=scripts python3 scripts\u002Fcore\u002Frecall_learnings.py \\\n  --query \"model routing [task description]\" --text-only\n```\n\nIf a prior attempt used a different tier and succeeded or failed, factor that into the context signal score.\n\n---\n\n## Anti-patterns\n\n| Anti-pattern | Why It Fails | Correct Behavior |\n|---|---|---|\n| Always specifying Opus \"to be safe\" | Slow, expensive, no learning signal | Score the task, use the right tier |\n| Always inheriting parent model | Complex sub-tasks get wrong model | Score independently, override when needed |\n| Using model as a retry strategy | Same model will fail the same way | If score warrants higher tier, upgrade |\n| Ignoring hard rules | Security bugs, data loss | Hard rules exist because the cost of failure is asymmetric |\n| Scoring once per session | Context changes, errors accumulate | Re-score on retry, re-score when context shifts |\n\n---\n\n## Checklist\n\nBefore routing any agent spawn or model selection decision:\n\n- [ ] Evaluated all three signal categories\n- [ ] Applied weights (0.3 \u002F 0.4 \u002F 0.3)\n- [ ] Checked distance from threshold boundary\n- [ ] Checked all hard rules\n- [ ] Logged the decision (TASK, SCORE, TIER, CONFIDENCE, HARD_RULE, MODEL, REASON)\n- [ ] Omitted `model` param if inheriting from parent\n\n**Remember**: The goal is the right model for the job. Not the most expensive one. Not the default one. The right one.\n",{"name":5,"description":7},"main","70e1c350500ee750987420bbae48837afa906b7e","skills\u002Fsmart-model-routing","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis","https:\u002F\u002Fgithub.com\u002Frubicanjr","linktr.ee\u002Ffinanskodu","Industrial Engineer & CIO @FinansKodu. Architecting AI-driven financial agents and autonomous workflows. 🏗️ Building systems, not just prompts.","2026-06-09 13:50:15",{"source":8,"skillName":5,"commands":50,"prompt":60,"zipAvailable":61},[51,54,57],{"tool":52,"command":53},"npx","npx skills add rubicanjr\u002FFinCognis --skill smart-model-routing",{"tool":55,"command":56},"bunx","bunx skills add rubicanjr\u002FFinCognis --skill smart-model-routing",{"tool":58,"command":59},"pnpm","pnpm dlx skills add rubicanjr\u002FFinCognis --skill smart-model-routing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fsmart-model-routing\u002FSKILL.md",true,[],[64,85,94,114,144,162],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":75,"publishedAt":36},"01M6NWS9DAXJTADT4T5MB49X8W","workflow-router","Goal-based workflow orchestration - routes tasks to specialist agents based on user goals","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow-router\u002FSKILL.md",[70],{"categoryNo":71,"categoryName":72,"taxonomyType":73,"taxonomyTypeDesc":74},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[76,77,78,79,80,81,82,83,84],"workflow router","workflow","router","orchestration","goals","goal","user","workflow orchestration","tasks",{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":36},"01M6NWS3RETSC0SHP16HP66E14","wiring","Wiring Verification","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fwiring\u002FSKILL.md",[],[87,92,93],"verification","false",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":103,"publishedAt":36},"01M6NWS0XW9CVQZBDA1EGW0TWC","websocket-patterns","Connection management, room patterns, reconnection strategies, message buffering, and binary protocol design.","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fwebsocket-patterns\u002Fskill.md",[100],{"categoryNo":101,"categoryName":102,"taxonomyType":73,"taxonomyTypeDesc":74},"01JBSEEDCAT000000000000015","视觉设计",[104,105,106,107,108,109,110,111,112,113],"websocket","patterns","websocket patterns","design","protocol","management","message","strategies","binary","connection",{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":124,"publishedAt":36},"01M6NWRDQDX9ZNETAWRRMQWV52","visual-verdict","Screenshot comparison QA for frontend development. Takes a screenshot of the current implementation, scores it across multiple visual dimensions, and returns a structured PASS\u002FREVISE\u002FFAIL verdict with concrete fixes. Use when implementing UI from a design reference or verifying visual correctness.","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fvisual-verdict\u002FSKILL.md",[120,123],{"categoryNo":121,"categoryName":122,"taxonomyType":73,"taxonomyTypeDesc":74},"01JBSEEDCAT000000000000009","前端开发",{"categoryNo":71,"categoryName":72,"taxonomyType":73,"taxonomyTypeDesc":74},[125,126,127,128,129,130,131,132,133,134,135,136,137,107,138,139,140,141,142,143],"visual","verdict","visual verdict","ui","across","revise","comparison","correctness","implementing","for","fixes","dimensions","frontend","development","qa","screenshot","returns","use","frontend development",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":36},"01M6NWR8HSNRS7MNDK2J02QYMN","verification-loop","Comprehensive verification system covering build, types, lint, tests, security, and diff review before a PR.","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[151,152,92,153,154,155,156,22,157,158,159,160,161],"verification loop","loop","lint","review","security","pr","diff","build","tests","diff review","types",{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":168,"publishedAt":36},"01M6NWR4HHSFR0VR5EXFRWA747","vector-db-patterns","Embedding strategies, ANN algorithms, hybrid search, RAG chunking strategies, and reranking for semantic search and retrieval.","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fvector-db-patterns\u002Fskill.md",[],[169,170,171,172,105,173,174,175,176,111,177,178,179,180,181,134,182,183],"vector db patterns","vector db","db","vector","semantic search","search","embedding strategies","algorithms","chunking","semantic","retrieval","embedding","Hybrid Search","hybrid","rag"]