Overview
Model preferences allow you to automatically route different types of tasks to appropriate Claude models. Use faster, cheaper models for simple tasks and reserve powerful models for complex work.Configuration
Define model preferences in your project’sconfig.json:
config.json
Model for small fixes, typos, imports, formatting
Model for new feature implementation
Model for code refactoring and restructuring
Model for architectural decisions and design
Model for complex debugging and investigation
Available Models
Claude Code supports multiple Claude models with different capabilities:| Model | Shorthand | Best For | Speed | Cost |
|---|---|---|---|---|
| Claude 3.5 Haiku | haiku | Quick fixes, simple edits, formatting | ⚡⚡⚡ | $ |
| Claude 3.5 Sonnet | sonnet | Features, general development | ⚡⚡ | $$ |
| Claude 3 Opus | opus | Complex reasoning, architecture | ⚡ | $$$ |
| Claude 4.5 Sonnet | claude-4.5-sonnet | Latest capabilities | ⚡⚡ | $$ |
Model preferences are guidance for Claude Code’s routing logic. The system may override preferences based on context complexity, token usage, or explicit user model selection.
Task Categories
Quick Fixes
Model: Haiku (fastest, cheapest) Use cases:- Fix typos and formatting
- Add missing imports
- Adjust whitespace/indentation
- Simple variable renames
- Update documentation strings
Features
Model: Sonnet (balanced) Use cases:- Implement new functionality
- Add API endpoints
- Create UI components
- Write business logic
- Integrate third-party libraries
Refactors
Model: Opus (most capable) Use cases:- Restructure code organization
- Extract abstractions
- Improve design patterns
- Optimize algorithms
- Large-scale renames
Architecture
Model: Opus (most capable) Use cases:- Design system architecture
- Plan database schemas
- Choose technology stack
- Design API contracts
- Security reviews
Debugging
Model: Opus (most capable) Use cases:- Trace complex bugs
- Analyze race conditions
- Debug memory issues
- Investigate performance problems
- Root cause analysis
Agent-Specific Model Overrides
Override model preferences for specific agents:agents/researcher.md
agents/quick-fixer.md
Why agent-specific models?
Why agent-specific models?
- Cost optimization: Use cheap models for constrained agents
- Performance: Fast models for quick tasks
- Capability matching: Complex agents get powerful models
- Explicit control: Override preferences when you know better
Command-Level Overrides
Set model preferences in command definitions:commands/deep-refactor.md
commands/quick-format.md
Skill-Level Overrides
Skills can specify model requirements:skills/security-review/SKILL.md
Hook-Level Model Control
Hooks support model specification:hooks.json
Runtime Model Selection
Users can override model preferences at runtime:Cost Optimization Strategies
Strategy 1: Conservative Defaults
Start cheap, escalate only when needed:Strategy 2: Performance First
Use powerful models for everything (faster iteration, higher cost):Strategy 3: Balanced (Recommended)
Optimize for both cost and capability:Performance Comparison
Token Generation Speed
| Model | Tokens/sec (est) | 1000 token response |
|---|---|---|
| Haiku | ~100 | ~10 seconds |
| Sonnet | ~60 | ~17 seconds |
| Opus | ~40 | ~25 seconds |
Speed varies by context size, complexity, and API load. These are approximate averages.
Quality vs Speed Tradeoff
Monitoring Usage
Track model usage and costs:Budget Controls
Best Practices
Match Task Complexity
Use Haiku for simple tasks, Opus for complex reasoning. Don’t overspend on trivial edits.
Fast Feedback Loops
Haiku in hooks for instant validation. Opus only when deep analysis is required.
Agent Specialization
Create focused agents with appropriate models. Quick-fix agents use Haiku, architects use Opus.
Monitor and Adjust
Track costs with
/usage and /cost. Adjust preferences based on actual spending patterns.Example Configurations
Troubleshooting
Model preferences not being respected
Model preferences not being respected
Cause: Explicit model set via CLI or
/model command overrides preferencesFix: Remove CLI --model flag or reset with /model autoUnexpected high costs
Unexpected high costs
Cause: All tasks routing to Opus due to misconfigurationFix: Review preferences and ensure Haiku/Sonnet are used for simpler tasks. Check
/cost frequently.Poor quality with Haiku
Poor quality with Haiku
Cause: Task too complex for Haiku’s capabilitiesFix: Reclassify task or manually switch to Sonnet/Opus for current session
Preferences file not loading
Preferences file not loading
Cause:
config.json not in expected location or has syntax errorsFix: Validate JSON syntax and ensure file is in project root or ~/.claude/Next Steps
Settings
Configure core Claude Code behavior
Quality Gates
Set up validation checkpoints
Agent Configuration
Create specialized agents with model preferences
Cost Management
Learn advanced cost optimization techniques