model-selection
Choose appropriate model for custom agent tasks. Use when selecting between Haiku, Sonnet, and Opus for agents, optimizing cost vs quality tradeoffs, or matching model capability to task complexity.
What this skill does
# Model Selection Skill
Choose the right model for custom agent tasks based on complexity, cost, and performance requirements.
## Interactive Model Selection
Use AskUserQuestion to understand requirements and recommend the optimal model:
```yaml
# Question 1: Primary Priority (MCP: CLI best practices - tradeoff selection)
question: "What is your primary priority for this agent?"
header: "Priority"
options:
- label: "Cost Efficiency (Recommended)"
description: "Minimize API costs, high-volume operations"
- label: "Balanced Performance"
description: "Good quality at reasonable cost for most tasks"
- label: "Maximum Quality"
description: "Best results regardless of cost, complex reasoning"
- label: "Lowest Latency"
description: "Real-time responses, user-facing interactions"
# Question 2: Task Complexity (MCP: Agent SDK model selection)
question: "How complex is the task this agent will perform?"
header: "Complexity"
options:
- label: "Simple"
description: "Transformations, extraction, formatting, classification"
- label: "Moderate"
description: "Code generation, analysis, planning, most tasks"
- label: "Complex"
description: "Architecture decisions, multi-step reasoning, critical code"
- label: "Variable"
description: "Mix of simple and complex tasks in one agent"
```
Use these responses to apply the decision tree and recommend the appropriate model.
## Purpose
Guide selection of appropriate Claude model (Haiku, Sonnet, Opus) for custom agent tasks to optimize cost, speed, and quality.
## When to Use
- Designing a new custom agent
- Optimizing existing agent performance
- Balancing cost vs quality
- Meeting specific latency requirements
## Model Overview
| Model | Speed | Cost | Quality | Use Case |
| --- | --- | --- | --- | --- |
| **Haiku** | Fastest | Lowest | Good | Simple tasks, high volume |
| **Sonnet** | Fast | Medium | Very Good | Most tasks, balanced |
| **Opus** | Slowest | Highest | Best | Complex reasoning |
## Selection Decision Tree
```text
START
│
├── Is task simple transformation?
│ └── YES → Haiku
│
├── Is cost the primary concern?
│ └── YES → Haiku (if adequate) or Sonnet
│
├── Is quality critical (no room for error)?
│ └── YES → Opus
│
├── Does task require complex reasoning?
│ └── YES → Opus
│
├── Is latency critical (real-time)?
│ └── YES → Haiku
│
└── DEFAULT → Sonnet (best balance)
```
## Model Selection by Task Type
### Haiku Tasks
Best for:
- Text transformations (uppercase, formatting)
- Simple classification
- Data extraction
- High-volume operations
- Real-time processing
- Pattern matching
```python
# Haiku examples
model="claude-3-5-haiku-20241022"
# Echo agent - simple transformation
# Calculator - straightforward math
# Stream processor - high volume, low complexity
```
### Sonnet Tasks
Best for:
- Code generation
- Code review
- Planning and analysis
- Most custom agents
- Balanced performance
```python
# Sonnet examples
model="claude-sonnet-4-20250514"
# QA agent - codebase analysis
# Builder agent - code implementation
# General-purpose agents
```
### Opus Tasks
Best for:
- Strategic planning
- Complex architectural decisions
- Critical code review
- Multi-step reasoning
- Novel problem solving
```python
# Opus examples
model="claude-opus-4-20250514"
# Planner agent - strategic decisions
# Reviewer agent - critical validation
# Architect agent - system design
```
## Cost Considerations
### Relative Costs
| Model | Input Tokens | Output Tokens | Relative Cost |
| --- | --- | --- | --- |
| Haiku | Low | Low | 1x |
| Sonnet | Medium | Medium | ~10x |
| Opus | High | High | ~30x |
### Cost Optimization Strategies
1. **Start with Haiku**: Test if simpler model is adequate
2. **Use Haiku for preprocessing**: Filter/classify before main task
3. **Reserve Opus for critical paths**: Only where quality is paramount
4. **Monitor costs**: Track `ResultMessage.total_cost_usd`
```python
# Cost tracking
async for message in client.receive_response():
if isinstance(message, ResultMessage):
print(f"Query cost: ${message.total_cost_usd:.6f}")
```
## Speed Considerations
### Latency Profiles
| Model | First Token | Total Time | Throughput |
| --- | --- | --- | --- |
| Haiku | ~500ms | Fast | Highest |
| Sonnet | ~1s | Medium | Good |
| Opus | ~2s | Slower | Lower |
### Speed Optimization
1. **Real-time needs Haiku**: Sub-second response
2. **Interactive needs Sonnet**: Acceptable latency
3. **Batch allows Opus**: Latency less critical
## Quality Considerations
### Capability Differences
| Capability | Haiku | Sonnet | Opus |
| --- | --- | --- | --- |
| Simple reasoning | ✓ | ✓ | ✓ |
| Code generation | Limited | Good | Excellent |
| Complex planning | Poor | Good | Excellent |
| Multi-step reasoning | Limited | Good | Excellent |
| Novel problems | Poor | Adequate | Excellent |
### Quality Requirements
- **Haiku**: Acceptable for well-defined, simple tasks
- **Sonnet**: Good for most development tasks
- **Opus**: Required for critical decisions
## Multi-Model Patterns
### Tiered Processing
```python
# Tier 1: Haiku for classification
classification = await classify_task(task, model="haiku")
# Tier 2: Route to appropriate model
if classification == "simple":
result = await process(task, model="haiku")
elif classification == "complex":
result = await process(task, model="opus")
else:
result = await process(task, model="sonnet")
```
### Multi-Agent with Different Models
```python
# Planner: Opus for strategic decisions
planner_options = ClaudeAgentOptions(
model="claude-opus-4-20250514"
)
# Builder: Sonnet for implementation
builder_options = ClaudeAgentOptions(
model="claude-sonnet-4-20250514"
)
# Reviewer: Opus for critical review
reviewer_options = ClaudeAgentOptions(
model="claude-opus-4-20250514"
)
```
## Output Format
When recommending model selection:
```markdown
## Model Selection
**Task:** [description]
**Recommended Model:** [Haiku/Sonnet/Opus]
### Decision Factors
| Factor | Weight | Assessment |
| --- | --- | --- |
| Complexity | [H/M/L] | [assessment] |
| Cost sensitivity | [H/M/L] | [assessment] |
| Quality requirement | [H/M/L] | [assessment] |
| Latency requirement | [H/M/L] | [assessment] |
### Rationale
[Why this model is appropriate]
### Alternatives
- If cost is concern: [alternative]
- If quality is critical: [alternative]
### Configuration
```
options = ClaudeAgentOptions(
model="[model-id]",
...
)
```text
```
## Selection Checklist
- [ ] Task complexity assessed
- [ ] Cost constraints identified
- [ ] Quality requirements defined
- [ ] Latency requirements considered
- [ ] Model selected with rationale
- [ ] Alternatives documented
## Key Insights
> "Choose wisely: Claude Haiku for simple, fast tasks. Claude Sonnet for balanced performance. Claude Opus for complex reasoning."
Model selection directly impacts:
- User experience (latency)
- Operational cost (tokens)
- Output quality (accuracy)
## Cross-References
- @core-four-custom.md - Model in Core Four
- @custom-agent-design skill - Agent design workflow
- @agent-deployment-forms.md - Deployment considerations
## Version History
- **v1.0.0** (2025-12-26): Initial release
---
## Last Updated
**Date:** 2025-12-26
**Model:** claude-opus-4-5-20251101
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.