AI Tools

How to Change Model in Claude Code

9 min read1,810 words2 views
How to Change Model in Claude Code

Claude Code has quietly become one of the most opinionated coding agents on the market, and part of that opinion shows up in how it handles model selection. Switching between Opus, Sonnet, and Haiku inside a single session can mean the difference between a fast, cheap autocomplete-style helper and a slow, expensive reasoning engine that untangles a gnarly bug. Knowing exactly how to flip that switch — and when you should — is one of the highest-leverage skills for anyone using Anthropic’s terminal-based coding tool in 2026.

Quick Answer: In Claude Code, change the active model by running the `/model` command inside a session and picking from the list (or typing `/model opus`, `/model sonnet`, or `/model haiku`), or by setting the `ANTHROPIC_MODEL` environment variable or the `model` field in your `settings.json` before launching, so the switch persists across sessions.

The Fastest Way: The /model Slash Command

The simplest, most reliable way to switch models is directly inside an active Claude Code session. Type `/model` at the prompt and hit enter, and Claude Code will show an interactive picker listing the models currently available to your account.

This works whether you’re on a Pro, Max, or API-billed plan, and the change takes effect immediately for the next message you send. You don’t need to restart the session, reload your terminal, or lose your conversation context.

  • Type `/model` alone to open the interactive selection menu
  • Type `/model opus` to jump straight to Claude Opus 4.5 without the menu
  • Type `/model sonnet` to switch to Claude Sonnet 4.5
  • Type `/model haiku` to switch to the lightweight Haiku tier
  • Type `/model default` to reset to whatever your account’s default assignment is

Anthropic rolled out this slash-command approach specifically so developers wouldn’t have to kill and relaunch Claude Code every time they wanted a different reasoning tier. Before this existed, switching models mid-task meant exporting a new environment variable and restarting — a genuinely annoying workflow break when you’re mid-debug.

Early testers of the `/model` command consistently flagged one thing: switching models does not erase your conversation history or file context. Claude Code keeps everything you’ve already loaded into the session, it just routes your next prompt to a different model.

Understanding What Each Model Actually Does Differently

Not all model switches are equal, and picking the wrong one for the task wastes either time or tokens. Claude Code currently exposes three primary tiers, each tuned for a different point on the speed-versus-depth spectrum.

Opus: The Heavy Reasoner

Claude Opus 4.5 is Anthropic’s top-tier model, and inside Claude Code it’s the one you want for architecture decisions, multi-file refactors, and debugging problems that require holding a lot of context in working memory. It’s noticeably slower per response and burns through usage limits faster, especially on Pro-tier subscriptions.

Sonnet: The Default Workhorse

Claude Sonnet 4.5 is what most Claude Code sessions run on by default, and for good reason. It strikes a balance between reasoning quality and speed that suits the bulk of day-to-day coding tasks — writing functions, fixing typical bugs, generating tests, and reading through moderate-sized codebases.

Haiku: The Speed Option

Haiku is the smallest and fastest model available inside Claude Code, and it’s best reserved for simple, mechanical tasks — renaming variables across a file, formatting JSON, writing boilerplate, or answering quick syntax questions. It’s rarely the right choice for anything involving genuine logical reasoning.

Model Best For Relative Speed Token Cost
Opus 4.5 Architecture, complex debugging, refactors Slowest Highest
Sonnet 4.5 Everyday coding, general default Moderate Moderate
Haiku Simple mechanical edits, quick answers Fastest Lowest

If you’re weighing Claude Code against other agentic coding tools before committing to a workflow built around this model-switching behavior, it’s worth reading a direct comparison like Claude Code vs GitHub Copilot to see how the underlying philosophies differ — Copilot doesn’t give you this same granular tier control inside a single tool.

Setting a Default Model Before You Even Launch

Switching per-session is great for one-off tasks, but if you consistently want a specific model every time you open Claude Code, you can bake that preference into your configuration instead of typing `/model` every single time.

There are two common ways developers lock in a default model:

  1. Environment variable — Set `ANTHROPIC_MODEL` in your shell profile (`.zshrc`, `.bashrc`, or equivalent) to a value like `claude-opus-4-5` before launching Claude Code, and every new session will start on that model automatically.
  2. Settings file — Edit the `model` field inside your Claude Code `settings.json` configuration, which lives in your project’s `.claude` directory or your global config folder depending on whether you want the setting per-project or system-wide.

The settings file approach is generally preferred by teams because it can be committed to version control, meaning every developer on a repository launches Claude Code with the same model tier by default. That consistency matters a lot when you’re trying to keep behavior predictable across a team, especially for tasks like automated test generation where model choice affects output quality — something explored in more depth in How to Use Claude Code for QA Automation.

  • Global settings apply to every project unless overridden locally
  • Project-level `.claude/settings.json` overrides the global default
  • Environment variables set at shell startup override both settings files
  • The `/model` command during a session overrides everything, but only for that session

Model Availability Depends on Your Plan and API Access

Not every Claude Code user sees the same options in the `/model` menu, and this trips people up constantly. Model access is gated by your subscription tier or your API key’s permissions, not just by what Anthropic has released.

Pro-tier subscribers typically get access to Sonnet and Haiku but may see Opus usage capped or unavailable depending on current plan terms, since Opus is the most compute-intensive model Anthropic runs. Max-tier subscribers and API-billed accounts generally get full access to all three tiers, with usage limited only by rate limits or token budgets rather than a hard tier restriction.

Newsletter
Get new SocialSpy articles and updates delivered to your inbox.
  • Free/Pro plans: Often limited to Sonnet as the primary model, with Haiku available for lighter tasks
  • Max plans: Typically unlock Opus access alongside Sonnet and Haiku, with higher usage caps
  • API key billing: Pay-as-you-go access to all available models, billed per token regardless of subscription tier

If you try to `/model opus` and it’s not available, Claude Code will usually tell you plainly rather than silently falling back, though the exact error message has changed across recent releases. Keeping Claude Code itself current matters here too, since new model releases and access changes often ship alongside version updates — a process covered thoroughly in How to Update Claude Code if you haven’t touched your installation in a while.

Why Model Switching Mid-Task Is a Real Strategy, Not Just a Preference

Experienced Claude Code users don’t pick one model and stick with it for an entire session — they treat model switching as a tactical move tied to the phase of the task. This is arguably the biggest workflow upgrade most casual users are missing.

A common pattern looks like this in practice:

  1. Start a new feature request on Opus to plan the architecture and identify which files need changes
  2. Switch to Sonnet with `/model sonnet` for the actual line-by-line implementation once the plan is clear
  3. Drop to Haiku for cleanup tasks like fixing lint warnings or renaming variables across the diff
  4. Switch back to Opus only if a genuinely hard bug surfaces during testing

This mirrors a pattern the broader AI industry keeps circling back to: bigger models for planning and judgment calls, smaller/faster models for high-volume mechanical execution. It’s the same tiered logic behind why companies keep shipping agent tools with model routing built in — the recently launched Muse Code from Meta takes a similar tiered approach for navigating large code bases, and it’s becoming close to an industry standard for agentic coding tools generally.

One practical reason to master this switching habit: Opus usage limits on Pro-tier plans can burn through your weekly quota in a single afternoon of heavy refactoring if you never step down to Sonnet or Haiku for the routine parts.

Common Mistakes and Troubleshooting

Even straightforward features like `/model` trip people up because of small inconsistencies between environment setup, terminal sessions, and plan permissions. A few issues show up constantly in developer forums and support threads.

  • The model resets unexpectedly: This usually means your `settings.json` or environment variable is overriding your in-session `/model` choice on the next launch — remember, `/model` changes only last for that session unless you also update your config.
  • Opus is greyed out or missing: Almost always a plan-tier limitation rather than a bug; check your subscription level before assuming something is broken.
  • Model switch doesn’t seem to change response quality: Confirm the switch actually took by checking the model name Claude Code displays in its status output; sometimes a typo like `/model opus4` fails silently and falls back to the previous model.
  • Team members see different defaults: Check whether your project’s `.claude/settings.json` is actually committed to the repo, since local-only settings files won’t sync across teammates’ machines.
  • Usage caps hit faster than expected: Track which model each session used; Opus consumes usage allowance dramatically faster than Sonnet or Haiku on the same plan.

Most of these issues are configuration layering problems rather than actual software bugs, and they resolve quickly once you understand the override hierarchy — session command beats environment variable beats settings file beats account default.

Conclusion

Model switching in Claude Code isn’t a hidden power-user trick anymore — it’s a core part of using the tool efficiently, and Anthropic clearly built the `/model` command with the expectation that developers would shift tiers constantly within a single working session. The real skill isn’t memorizing the command syntax, which takes about thirty seconds to learn; it’s developing the instinct for when a task genuinely needs Opus-level reasoning versus when Sonnet or Haiku will get the job done for a fraction of the usage cost. Get that instinct right, and Claude Code stops feeling like an expensive black box and starts feeling like a tool you’re actually driving with intention.

FAQ

Run `/model` without any arguments and the interactive menu will highlight your currently active model at the top of the list, or check the status line Claude Code often displays at the start of a response, which typically names the model handling that specific reply.

No, switching models with the `/model` command preserves your entire conversation history, loaded files, and working context; only the model generating the next response changes, so you can freely move between Opus, Sonnet, and Haiku without restarting your session.

Yes, by committing a `.claude/settings.json` file with the `model` field set to your preferred default inside the project repository, every teammate who pulls that repo and runs Claude Code will inherit the same default model setting automatically.

Leave a Comment

Your email address will not be published. Required fields are marked *

Never miss an update
Get new SocialSpy articles straight to your inbox.
Scroll to Top