Steve Kinney

Claude Code Model Selection

Claude Opus and Claude Sonnet represent different points on an “agency spectrum” for AI coding systems. I guess there is also Haiku.

Claude Opus: The “Development Partner” for Complexity

Opus is considered the highest capability model and demonstrates genuine development partnership, capable of internalizing objectives, working persistently, and proactively identifying and resolving obstacles. It’s ideal for tasks requiring maximum reasoning and complex trade-offs.

Key Use Cases for Opus

  • Creative tasks requiring nuanced understanding.
  • Code reviews requiring architectural judgment.
  • Complex refactoring across multiple systems.
  • Large-scale system design.
  • Complex algorithm development.
  • Research and advanced analysis.
  • Multi-system integration.
  • Advanced problem solving.
  • Machine Learning architecture.
  • Advanced technical writing.
  • High-level planning and final review.
  • Initial builds based on project plans in CLAUDE.md.
  • Adding entire new modules.
  • Thorough codebase analysis and architectural understanding.
  • Complex root cause analysis for debugging.
  • Integrating disparate information sources for comprehensive understanding.
  • Creating final integrated reports and strategic proposals.

Opus excels at strategic-level analysis and makes more cautious and iterative approaches, often using more turns (interactions) to complete a task. For instance, Claude Opus 4 needed only two follow-up prompts to create a fully functional OmniFocus plugin and proactively enhanced it with configuration interfaces, error handling, input validation, and progress indicators. It can even autonomously decide tradeoffs and dynamically adjust resource allocation and review cycles for quality.

Claude Sonnet: The “Collaborative Agent” and Production Workhorse

Sonnet is seen as a production standard model and acts as a collaborative agent that balances instruction-following with initiative, working semi-autonomously with periodic guidance. It is a great workhorse suitable for standard feature implementation and development tasks. Many users find Sonnet perfectly adequate for most coding tasks.

Key Use Cases for Sonnet

  • Standard feature implementation and development tasks.
  • Most debugging and troubleshooting scenarios.
  • Code generation with moderate complexity.
  • Documentation writing and editing.
  • Task coordination and workflow management.
  • Enterprise applications.
  • Security-critical code.
  • Standard system architecture.
  • Code reviews requiring adherence to standards.
  • Compliance audits.
  • Customer-facing projects and open-source projects.
  • Creating secure user authentication systems.
  • General implementation tasks.
  • Structural analysis (directory structure, configuration files).
  • Pattern extraction (code conventions, naming rules).
  • Data transformation (CSV generation, mapping creation).
  • Routine investigation tasks.
  • Small, specific tasks that require less “thinking” or “creativity”.
  • Debugging production issues.

Sonnet is generally faster and cheaper than Opus, making it the default choice for most users. It can handle complex tasks but might require more explicit guidance at the development stage compared to Opus.

Claude Haiku: The “Responsive Assistant” for Simple, Fast Tasks

While not the main focus, Haiku is the cheapest and fastest model, best suited for simple, routine tasks that do not require complex reasoning or extensive context. It is recommended for:

  • Simple file reads and basic content extraction.
  • Routine formatting and style corrections.
  • Basic syntax validation and linting.
  • Simple text transformations and data parsing.
  • Quick status checks and basic analysis.
  • Simple utility scripts or throwaway code.

Haiku provides the most compact output and generally uses the fewest turns.

Performance and Cost Implications

Using Claude Code, especially Opus, can be expensive.

  • Cost: Opus is approximately 5 times more expensive than Sonnet, and about 20 times more expensive than Haiku.
  • Speed: Haiku is the fastest (27 seconds for a test task), followed by Opus (76 seconds), and then Sonnet (86 seconds). However, some sources suggest Sonnet can be faster for quick answers.
  • Output Detail: Sonnet often provides the most detailed output in terms of token count, followed by Opus, and then Haiku.
  • Context Window: Claude models offer large context windows, like Claude 2 with up to 100k tokens. However, continuously long conversations can lead to degraded responses and increased token usage.

Cost Optimization Strategies

  • Hybrid Model Approach: Use the more expensive models (like Opus) only for critical, low-frequency tasks (e.g., high-level planning, final review) and cheaper, faster models (like Sonnet) for the bulk of high-frequency implementation work. For example, use Opus for the foundational understanding phase, then switch to Sonnet for implementation, and back to Opus for review.
  • Context Management: Regularly use /clear to reset conversation history, especially when switching tasks, to prevent irrelevant context from increasing token usage. The /compact command can summarize the conversation, reducing token count while retaining important context. Claude Code can even auto-compact when it reaches 95% capacity.
  • Prompt Caching / Foundation Session: Utilizing a “foundation session” can drastically reduce token costs by caching the initial large context prompt and reusing it across subsequent calls. This can lead to 60-90% token cost reduction and faster execution.
  • Fixed-Cost Subscription Plans: Plans like Anthropic’s Claude Max offer predictable costs, de-risking experimentation with large-scale agent usage.
  • Safeguards: For automated workflows, configure limits on maximum turns (--max-turns) or runtime to prevent runaway costs.

How to Choose Which Model to Use

The choice of model depends on the task complexity, quality requirements, and cost considerations.

General Guidelines (5-Second Rule)

  • If you spend more than 5 seconds thinking about which model to use:
    • For complex design/research: Use opus.
    • For everything else: Use sonnet.
  • The quality difference can be significant, so when in doubt, choose the higher capability model.

Decision Tree / Scenarios

  • Highest complexity/scale work, research, advanced analysis, architectural judgment: Opus.
  • Production use, security/auth, standard enterprise applications, code reviews, compliance audits: Sonnet.
  • Simple utilities/scripts, basic file operations, routine formatting, personal/throwaway code: Haiku.
  • Red Flags: Always use Sonnet if user data, money/payments, authentication/authorization, external API integration, database operations, concurrent operations, file uploads, email sending, cryptographic operations, or third-party dependencies are involved.

Migration Checklist from Haiku to Sonnet (or higher): Upgrade from claude-3-5-haiku-20241022 to Sonnet when:

  • Adding authentication.
  • Connecting to a database.
  • Handling user input.
  • Going to production.
  • Others will use the code.
  • Security matters.
  • Performance matters.

How to Switch Models in Claude Code

You can switch models using the /model slash command within an interactive Claude Code session. For example, type /model and then select from the available options (e.g., Opus, Sonnet, or a specific full model name like claude-sonnet-4-20250514 or claude-3-5-haiku-20241022). Alternatively, you can specify the model directly when starting Claude Code using the --model flag: claude --model claude-opus-4-20250514.

Leveraging CLAUDE.md for Enhanced Model Performance

Regardless of the model chosen, providing relevant context significantly improves Claude Code’s output quality. The CLAUDE.md file is a special Markdown file that Claude automatically reads at the start of every session, serving as a persistent, project-specific memory and instruction manual.

  • Adherence Hierarchy: CLAUDE.md instructions are treated as immutable system rules that define operational boundaries, taking precedence over user prompts, which are interpreted as flexible requests. This ensures consistent process execution and persistent context.
  • Content: Use CLAUDE.md to document project architecture, coding standards, common commands, core files, project workflows, and any unexpected behaviors or warnings.
  • Modularity: For larger projects, link to other Markdown files (e.g., @docs/testing.md) within your CLAUDE.md to keep the main file concise and prevent “instruction bleed”. This allows Claude to pull in specific files only when relevant, optimizing token usage.
  • Refinement: Treat CLAUDE.md as a living document that you constantly refine based on Claude’s performance. You can quickly add instructions by typing # at the start of your input, which prompts Claude to store it in CLAUDE.md.
  • Hierarchical Memory: Claude reads CLAUDE.md files from your user directory (~/.claude/CLAUDE.md) for global preferences, and then from the project root (./CLAUDE.md) for project-specific guidelines, and also from subdirectories. This allows for granular control.
  • Clarity and Specificity: Be explicit and detailed in your instructions, using Markdown headings and bullet points for organization. Avoid vague requests.

Last modified on .