Skip to main content

How to Change Claude Code Model

I switch between Claude models based on task complexity and token efficiency. Sonnet 4 for daily development work, Opus 4 when I need deep reasoning for architectural decisions.

How to Use It

Environment Variable - Set the default model in your shell configuration:

# Set default model (add to `~/.bashrc` or `~/.zshrc`)
export ANTHROPIC_MODEL="claude-sonnet-4-20250514"

# Alternative model
export ANTHROPIC_MODEL="claude-opus-4-20250514"

Command Line Flag - Specify model when starting Claude Code:

# Start with Sonnet 4
claude --model claude-sonnet-4-20250514

# Start with Opus 4
claude --model claude-opus-4-20250514

Mid-Session Switching - Change models during active sessions:

# Full model names
/model claude-opus-4-20250514
/model claude-sonnet-4-20250514

# Shorthand commands (easier to type)
/model opus
/model sonnet

# Alternative shorthand
/mode opus
/mode sonnet

Why Use Different Models

Each Claude model excels in different scenarios, and switching between them optimizes both performance and cost efficiency based on task requirements.

Benefits:

  • Task Optimization - Match model capabilities to specific development needs and complexity levels
  • Cost Management - Use less expensive models for simpler tasks while reserving premium models for complex work
  • Performance Balance - Optimize response speed and quality based on urgency and complexity requirements
  • Token Efficiency - Manage usage limits by selecting appropriate models for different types of work
  • Workflow Flexibility - Adapt model selection to changing requirements within the same development session

Model Selection Strategy

Claude 4 Sonnet - Default choice for balanced performance:

  • Daily coding tasks and bug fixes
  • Code reviews and documentation
  • Most refactoring and testing work
  • General development activities

Claude 4 Opus - Complex reasoning and analysis:

  • Architectural decisions and design patterns
  • Large-scale refactoring across multiple files
  • Performance optimization analysis
  • Complex debugging and problem-solving
Session Management

Switching models mid-session increases token consumption because the new model must process the entire conversation history. Consider starting fresh sessions when changing models for long conversations.

Strategic Selection

Start with claude --model claude-sonnet-4-20250514 for most work. Switch to Opus 4 with /model opus only when encountering problems requiring deeper reasoning.

See Also: Model Switching Guide|Configuration|Getting Started