Skip to main content

Lesson 8: AI Model Selection

Time: 25 minutes Goal: Optimize cost and quality by choosing the right model


Claude Models

ModelBest ForCostSpeed
Opus 4.5Architecture, complex analysis$$$Slower
Sonnet 4.5Daily coding, features, tests$$Fast
Haiku 3.5Quick lookups, simple edits$Fastest

The most expensive model isn't always best. Using Opus for a typo is like a sledgehammer for a thumbtack.


When to Use Each Model

Opus 4.5

✅ Architecture decisions
✅ Complex multi-file refactoring
✅ System design
✅ Security reviews
✅ Comprehensive specs

Example commands:

/specweave:increment "..."  # Uses Opus for planning
/specweave:qa 0001 # Uses Opus for analysis

Sonnet 4.5

✅ Feature implementation
✅ Writing tests
✅ Bug fixes
✅ Code reviews
✅ Daily development

Example commands:

/specweave:do   # Uses Sonnet for execution

Haiku 3.5

✅ Quick lookups
✅ Simple file edits
✅ Bulk find-and-replace
✅ Syntax checks

Example:

"What's the export name in utils/constants.ts?"
"Change button color from blue to green"

SpecWeave Default Selection

SpecWeave picks automatically:

/specweave:increment    → Opus (complex planning)
/specweave:do → Sonnet (balanced execution)
/specweave:qa → Opus (deep analysis)
/specweave:sync-progress → Haiku (fast sync)

Cost Optimization

Strategy 1: Progressive Escalation

Start cheap, escalate as needed:

Step 1: Haiku exploration
"What files handle authentication?"
Cost: ~$0.001

Step 2: Sonnet analysis
"Explain the auth flow"
Cost: ~$0.02

Step 3: Opus architecture (if needed)
"Redesign for multi-tenant"
Cost: ~$0.15

Strategy 2: Batch Similar Tasks

❌ Expensive: 10 separate Opus calls
"Fix typo in file1.ts"
"Fix typo in file2.ts"
...

✅ Cheap: 1 Haiku bulk operation
"Fix all typos: file1.ts, file2.ts, ..."

Strategy 3: Explore First

# Cheap exploration with Haiku
/specweave:do --explore-only

# Then implement with Sonnet
/specweave:do --continue

Real-World Example

Task: "Add payment processing"

PhaseModelCostAction
ResearchHaiku$0.005Find existing code
PlanningOpus$0.20Create increment
ImplementationSonnet$1.20Build 8 tasks
Total$1.40vs $3.00 all-Opus

Configuration

Default Models

In .specweave/config.json:

{
"ai": {
"defaultModel": "sonnet",
"planningModel": "opus",
"explorationModel": "haiku"
}
}

Per-Increment Override

In spec.md frontmatter:

---
increment: 0001-complex-refactor
ai:
model: opus # Use Opus throughout
---

Quick Reference

┌─────────────────────────────────────────────────────────┐
│ WHICH MODEL? │
├─────────────────────────────────────────────────────────┤
│ │
│ "I need to..." │
│ │
│ Design / Architect ────────────► OPUS 4.5 │
│ Complex refactor │
│ Security review │
│ │
│ Write features ────────────► SONNET 4.5 │
│ Fix bugs │
│ Write tests │
│ │
│ Quick lookup ────────────► HAIKU 3.5 │
│ Simple edit │
│ Bulk operation │
│ │
└─────────────────────────────────────────────────────────┘

Glossary Terms Used

  • LLM — Large Language Model
  • Inference — Using trained models

Key Takeaways

  1. Start cheap (Haiku), escalate as needed
  2. Use Opus for planning, Sonnet for execution
  3. Batch similar operations
  4. Cache exploration results

What's Next?

Learn how to fix common issues.

:nextLesson 9: Troubleshooting