Model Switching
Scannednpx machina-cli add skill silvesterdivas/context-engineer/model-switching --openclawModel Switching Guide
Match task complexity to the right model. Using Opus for simple searches wastes money; using Haiku for architecture decisions wastes time.
Model-Task Matrix
Haiku (Fast, Cheap)
Best for tasks that are simple, repetitive, or involve searching:
- File search & grep — Finding files, searching for patterns
- Simple code edits — Renaming variables, fixing typos, adding imports
- Quick lookups — Checking a function signature, reading a config value
- Boilerplate generation — Test scaffolding, interface stubs, CRUD operations
- Status checks — Git status, running simple commands
- Data extraction — Pulling specific values from files or outputs
Use via: Investigator agent, or model: "haiku" in command frontmatter.
Sonnet (Balanced)
Best for tasks that require understanding and multi-step reasoning:
- Code review — Reading and evaluating code quality, patterns, bugs
- Refactoring — Restructuring code while preserving behavior
- Multi-file changes — Coordinated edits across several files
- Bug investigation — Following call chains, understanding data flow
- Feature implementation — Standard features with clear requirements
- Test writing — Understanding code to write meaningful tests
Use via: Reviewer agent, or model: "sonnet" in command frontmatter.
Opus (Powerful, Expensive)
Reserve for tasks that require deep reasoning or creativity:
- Architecture decisions — System design, technology choices, trade-offs
- Complex debugging — Race conditions, memory leaks, subtle logic errors
- Security review — Vulnerability analysis, threat modeling
- Performance optimization — Algorithmic improvements, profiling analysis
- Novel problem solving — Unusual requirements, creative solutions
- Cross-system integration — Understanding how multiple systems interact
Use via: Default model in most configurations, or explicit model: "opus".
Cost Ratios (Approximate)
| Model | Relative Cost | Speed |
|---|---|---|
| Haiku | 1x | Fastest |
| Sonnet | 5x | Medium |
| Opus | 25x | Slowest |
Decision Heuristic
Apply this decision heuristic:
- Is this a search or lookup? → Haiku
- Does this require reading and understanding code? → Sonnet
- Does this require creative reasoning or weighing trade-offs? → Opus
- Unsure? → Start with Sonnet, escalate to Opus if stuck
Subagent Delegation
When delegating to subagents via the Task tool:
- Set
model: "haiku"for investigation and search tasks - Set
model: "sonnet"for review and implementation tasks - Leave model unset (inherits parent) for tasks that need full capability
Source
git clone https://github.com/silvesterdivas/context-engineer/blob/main/skills/model-switching/SKILL.mdView on GitHub Overview
Model Switching guides selecting the appropriate AI model (Haiku, Sonnet, Opus) based on task complexity. It helps prevent wasted compute by matching task type to the right tier and supports delegating work to subagents with correct model contexts.
How This Skill Works
The skill uses a simple decision heuristic: if the task is a quick search or lookup, use Haiku; if it requires reading and understanding code, use Sonnet; for creative reasoning or deep analysis, use Opus. Subagents can be delegated by setting the model in the command frontmatter or allowing the parent model to be inherited when full capability is needed.
When to Use It
- You need a fast, cheap task like file search, pattern matching, or boilerplate generation (Haiku).
- You must perform code review, refactoring, or multi-file changes that require understanding and planning (Sonnet).
- You face architecture decisions, security reviews, performance tuning, or complex debugging (Opus).
- You are delegating work to subagents and need clear model tiers for investigation, review, or full capability tasks.
- You’re unsure which model to use and want a guided start, escalating from Sonnet to Opus if needed.
Quick Start
- Step 1: Assess the task type using the decision heuristic: search/lookup → Haiku; code understanding → Sonnet; creative/reasoning → Opus.
- Step 2: Set the model in frontmatter (haiku, sonnet) for subagents, or leave unset to use the default Opus.
- Step 3: If results aren’t satisfactory, escalate from Sonnet to Opus and re-evaluate the task.
Best Practices
- Apply the Model-Task Matrix to categorize tasks before execution.
- Reserve Opus for tasks demanding deep reasoning or creative problem solving.
- For simple searches, opt for Haiku to minimize cost and time.
- Explicitly set model in the command frontmatter when delegating to subagents.
- If unsure, start with Sonnet and escalate to Opus only if necessary.
Example Use Cases
- Use Haiku for file search & grep, simple code edits, and quick lookups.
- Use Haiku for boilerplate generation like test scaffolding or CRUD stubs.
- Use Sonnet for code reviews, multi-file changes, and understanding complex code paths.
- Use Opus for architecture design, security reviews, and cross-system integrations.
- When in doubt, begin with Sonnet and escalate to Opus for deeper analysis.