agentleFS
FaisalAlqarniFaisalAlqarni/sp-ecc/skills/model-routing/SKILL.md

model-routing

Skill9 starsChanged 10 months agoMITView on GitHub

Detailed model routing framework. Provides task classification, bug complexity scoring, escalation triggers, and cost optimization patterns for Opus/Sonnet/Haiku tiers.

15 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use Opus ONLY for:

    line 21
  2. Distinctive:

    When given a complex task, decompose it:

    line 129
  3. Distinctive:

    Default to Sonnet: when uncertain—it handles most tasks well at moderate cost.

    line 171
  4. Distinctive:

    Avoid these costly mistakes:

    line 175

“Common” is measured: kept by at least 6 in 10 of the 14 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Model Routing

Route tasks to the most cost-effective model while maintaining quality.

Model Tiers

TierModelCostUse For
Opusclaude-opus-4-6$$$Complex reasoning, architecture, planning
Sonnetclaude-sonnet-4-6$$Implementation, code execution, debugging
Haikuclaude-haiku-4-5$Simple edits, docs, formatting, boilerplate

Task Classification

Opus Tasks (Think/Plan)

Use Opus ONLY for:

  • System architecture and design decisions
  • Complex algorithm design
  • Multi-file refactoring strategy
  • Complex bugs (see criteria below)
  • Security vulnerability analysis
  • Performance optimization planning
  • Code review requiring deep reasoning
  • Breaking down ambiguous requirements

Sonnet Tasks (Execute/Build)

Use Sonnet for:

  • Writing new functions/classes/modules
  • Implementing planned features
  • Most debugging (start here, escalate if stuck)
  • Writing tests
  • Code refactoring (executing a plan)
  • API integrations
  • Database queries and migrations
  • Most day-to-day coding work

Bug Complexity Decision

Default to Sonnet for bugs. Escalate to Opus only when needed.

Quick Bug Scoring

Count these complexity signals (+1 each):

SignalExample
Multi-fileSpans 3+ files/services
No stack traceNo clear error location
IntermittentDoesn't always reproduce
ConcurrencyRace conditions, async issues
State-dependentNeeds specific event sequence
PerformanceMemory leak, CPU spike

Scoring:

  • 0-1 → Sonnet
  • 2-3 → Sonnet first, escalate if stuck after 2-3 attempts
  • 4+ → Opus

Escalation Rule

Escalate to Opus when ANY trigger fires:

TriggerThreshold
Failed fixes≥3 attempts didn't resolve
Circular investigationRevisiting same files 2+ times
Scope expansionStarted with 1-2 files, now 5+
Hypotheses disproven3+ theories tested and failed
Mystery fixFixed it but don't know why
Complexity discoveredFound race condition/state issue

Self-check after each attempt:

Fixes tried: [N] | Files touched: [N] | Confidence: [H/M/L]
If confidence=LOW and fixes≥2 → Opus

Haiku Tasks (Simple/Apply)

Use Haiku for:

  • Adding/updating comments and docstrings
  • Formatting and linting fixes
  • Renaming variables/functions
  • Simple boilerplate generation
  • Applying documentation templates
  • Repetitive mechanical changes
  • Copy-paste adaptations
  • Import statement organization
  • Simple find-and-replace operations
  • Generating standard config files

Decision Flow

┌─────────────────────────────────────┐
│         Incoming Task               │
└──────────────┬──────────────────────┘
               │
               ▼
┌─────────────────────────────────────┐
│ Does it require deep reasoning,     │
│ planning, or architecture?          │
└──────────────┬──────────────────────┘
               │
        Yes    │    No
     ┌─────────┴─────────┐
     ▼                   ▼
┌─────────┐    ┌─────────────────────┐
│  OPUS   │    │ Is it mechanical,   │
│ (Plan)  │    │ repetitive, or      │
└─────────┘    │ documentation-only? │
               └──────────┬──────────┘
                          │
                   Yes    │    No
                ┌─────────┴─────────┐
                ▼                   ▼
           ┌─────────┐        ┌─────────┐
           │  HAIKU  │        │ SONNET  │
           │ (Apply) │        │ (Build) │
           └─────────┘        └─────────┘

Implementation Pattern

When given a complex task, decompose it:

1. OPUS PHASE: Analyze and plan
   - Understand requirements
   - Use brainstorm skill if needed to be fully aligned with the user
   - Design architecture
   - Create implementation steps
   - Identify edge cases

2. SONNET PHASE: Execute the plan
   - Write core logic
   - Review code, return to previous step if found issue
   - Implement features
   - Review again, return to previous step if found issue, or to Write core logic if needed. make it a loop until the reviews are passed successfuly
   - Write tests
   - Debug issues
   - again, final review

3. HAIKU PHASE: Polish and finalize
   - Add docstrings
   - Format code
   - Update README
   - Apply boilerplate

Cost Savings Examples

TaskWithout RoutingWith RoutingSavings
Plan + Build featureAll OpusOpus→Sonnet~60%
Build + DocumentAll OpusSonnet→Haiku~80%
Full workflowAll OpusOpus→Sonnet→Haiku~70%

Quick Reference

Ask yourself:

  1. "Do I need to THINK deeply?" → Opus
  2. "Do I need to BUILD something?" → Sonnet
  3. "Do I need to APPLY changes mechanically?" → Haiku

Default to Sonnet when uncertain—it handles most tasks well at moderate cost.

Anti-Patterns

Avoid these costly mistakes:

  • ❌ Using Opus for simple code formatting
  • ❌ Using Opus to add docstrings
  • ❌ Using Sonnet for mechanical find-replace
  • ❌ Using Haiku for complex debugging
  • ❌ Using Haiku to design architecture

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.