Claude Code - Model Configuration
Learn how to configure and switch between Claude AI models using aliases, settings, and environment variables
In the previous chapter, we explored Claude Code’s built-in tools and permission system. Now let’s learn how to configure which AI model Claude Code uses for different tasks.
Model Aliases
Claude Code provides convenient aliases that automatically map to the latest model versions:
| Alias | Current Model | Use Case |
|---|---|---|
default |
Recommended for your account type | Automatic best choice based on account |
sonnet |
Sonnet 4.5 | Daily coding tasks, balanced performance |
opus |
Opus 4.5 | Complex reasoning, architectural decisions |
haiku |
Haiku (latest) | Fast, simple tasks, background operations |
sonnet[1m] |
Sonnet with 1M token context | Long sessions, large codebases |
opusplan |
Opus (plan) → Sonnet (execution) | Hybrid: complex planning, efficient execution |
Using aliases ensures you automatically get the latest model versions without updating configuration.
Setting Your Model
Configure your model using one of these methods (listed by priority):
Switch models mid-session:
This temporarily changes the model for the current session only.
|
|
At Startup
Specify the model when starting Claude Code, setting the model for the entire session:
|
|
Environment Variable
Set a default model for all sessions, add to your .bashrc or .zshrc to make it permanent:
|
|
Settings File (Lowest Priority)
Configure permanently in .claude/settings.json:
|
|
Checking Your Current Model
Two ways to verify which model you’re using:
1. Status Command
|
|
Displays your current model along with account information.
2. Status Line
Configure the status line to always show the current model (see status line configuration).
Special Model Features
The opusplan Hybrid Model
The opusplan alias provides intelligent model switching:
- Plan Mode: Uses Opus for complex reasoning and architecture
- Execution Mode: Switches to Sonnet for code generation
This combines Opus’s deep reasoning with Sonnet’s efficient execution.
For other special model features visit Claude Code Special Model Features.
Model Selection Strategy
Choose your model based on the task:
Use Sonnet for:
- Daily coding tasks
- Bug fixes
- Component creation
- Refactoring
Use Opus for:
- Complex architectural decisions
- System design
- Debugging difficult issues
- Performance optimization strategies
Use Haiku for:
- Simple file edits
- Quick searches
- Documentation updates
- Formatting fixes
Use opusplan for:
- Large features requiring planning
- System-wide changes
- Complex integrations
Best Practices
- Start with
default- Let Claude Code choose the appropriate model - Use
sonnetfor most work - Balanced performance and cost - Reserve
opusfor complexity - Use when you need deeper reasoning - Try
opusplanfor features - Combines planning depth with execution efficiency - Switch mid-session when needed - Use
/modelto adapt to task complexity - Monitor usage - Check
/statusto track which model you’re using - Set per-project defaults - Use settings files for project-specific requirements
For complete model configuration details and updates, see the official model configuration documentation.
By understanding model configuration, you can optimize Claude Code’s performance, cost, and capabilities for different types of tasks.
