Part ofWhat Is Claude Code? The Complete Guide
In This Article
7 sectionsQuick answer
To change the model in Claude Code, type `/model` and pick from the list, or run `/model opus` (or `sonnet` / `haiku`) to switch instantly mid-session. To make a choice stick, launch with `claude --model opus` or set `ANTHROPIC_MODEL` in your shell. This guide covers how to change model in Claude Code every way — for one session and as your permanent default.
Switching models is one of the highest-leverage habits in Claude Code: Sonnet for the fast bulk of your work, Opus for the genuinely hard problems, Haiku for cheap throwaway tasks. We move between them constantly. Below is exactly how to change model in Claude Code — mid-session with a keystroke, at launch with a flag, and permanently through config — plus which one to reach for and what to do when the switch won't take.
Step 1: See which model Claude Code is using
Before you switch, check what's active so you can confirm the change. Type this in an interactive session:
/model
Run on its own, /model shows your current model and opens the picker listing every model you can select. You can also type /status to see the active model alongside your account and version. Knowing the starting point makes the next step unambiguous.
Step 2: How to change model in Claude Code with the /model command
The /model command is the fastest way to switch, and it's the answer most people are looking for. Pass an alias to jump straight to a model without touching the menu:
/model opus # switch to the latest Opus
/model sonnet # switch to the latest Sonnet
/model haiku # switch to the fast, cheap Haiku
The change applies immediately and lasts for the rest of the session. This is the core of how to change model in Claude Code on the fly — start a task on Sonnet, hit a hard architectural decision, type /model opus, and drop back to /model sonnet when the tricky part is done.
Step 3: How to change model in Claude Code permanently
/model only changes the current session. To set a default that every new session uses, you have three options — pick whichever fits your workflow:
- Launch flag — start Claude Code on a specific model for that run:
claude --model opus - Environment variable — set it once in your shell so every session inherits it. Add this to
.zshrcor.bashrc:export ANTHROPIC_MODEL="claude-sonnet-4-6" - Settings file — set the
modelkey in yoursettings.jsonfor a per-project or per-user default.
The environment variable is the cleanest permanent answer to how to change model in Claude Code for good, while --model is handy for one-off runs. All three are documented in the Claude Code model configuration reference.
How to change model in Claude Code to Opus, Sonnet, or Haiku
Claude Code accepts short aliases so you never have to type a full model ID. These are the ones worth knowing:
| Alias | What it selects |
|---|---|
sonnet | Latest Sonnet — the balanced daily-driver default |
opus | Latest Opus — deepest reasoning and hardest refactors |
haiku | Latest Haiku — fastest and cheapest for simple tasks |
best | The most capable model available to your plan |
sonnet[1m] | Sonnet with a 1M-token context window |
opus[1m] | Opus with a 1M-token context window |
opusplan | Opus during plan mode, then Sonnet for execution |
opusplan is the power move: you get Opus's planning quality where it matters most and Sonnet's speed and price for the actual edits. Use sonnet[1m] or opus[1m] when you're working across a large codebase that needs the extra context.
Which model should you switch to
Changing the model is only useful if you pick the right one. The rule of thumb: default to Sonnet, escalate to Opus when a mistake is expensive to catch.
| Task | Switch to |
|---|---|
| Everyday coding, tests, small fixes | sonnet |
| Large multi-file refactors, architecture | opus |
| Long autonomous agent runs | opus or opusplan |
| Bulk, simple, or throwaway work | haiku |
Sonnet now delivers most of Opus's coding quality at a fraction of the cost, so you'll stay on it more than you expect — we break down exactly where each wins in Claude Sonnet vs Opus. Model access also depends on your plan; Opus needs Max or API credits, which we cover in Claude Code cost.
Troubleshooting: the model won't change
If a switch doesn't take, it's almost always one of these:
- The model isn't on your plan. Opus requires Max or API access — on Pro,
/model opusmay be unavailable or capped. Anthropic's model configuration guide lists what each plan can select. - An environment variable is overriding you. A stale
ANTHROPIC_MODELin your shell config wins over expectations. Check withecho $ANTHROPIC_MODELand unset it if it's forcing the wrong model. - You edited settings mid-session. Config changes apply on the next launch — restart Claude Code after editing
settings.json.
That covers how to change model in Claude Code when the obvious command seems to do nothing. For the complete list of commands and config keys, see our Claude Code CLI documentation.
Model-switching workflows worth stealing
Knowing how to change model in Claude Code is one thing; knowing when is what saves time and money. These are the switching patterns we lean on every day, and they're the real reason the /model command matters:
- Plan on Opus, build on Sonnet. Type
/model opusplanand let Claude Code use Opus while it plans, then Sonnet while it edits — the single best default for any non-trivial feature. It pairs naturally with plan mode, where the planning quality pays off most. - Escalate mid-task, then step back down. Start on
sonnet, hit a gnarly bug or an architecture call, run/model opus, solve it, then/model sonnet. You pay Opus rates only for the few minutes you genuinely need them, which keeps your bill close to Sonnet's. - Drop to Haiku for grunt work. Bulk renames, log parsing, quick file summaries —
/model haikucosts a fraction of Sonnet and is plenty capable for mechanical tasks that don't need deep reasoning. - Pin a default per project. A repo that always needs deep reasoning can set
ANTHROPIC_MODELin a project-level config, so every session there opens on Opus without a manual switch.
The point of learning how to change model in Claude Code isn't to fiddle with settings — it's to match the model to the moment. Most of your day lives comfortably on Sonnet; the real wins come from the deliberate jumps up to Opus for hard problems and down to Haiku for cheap, high-volume work.
| Situation | Command | Why |
|---|---|---|
| New feature, unsure of approach | /model opusplan | Opus plans, Sonnet executes |
| Sudden hard bug or design call | /model opus | Deepest reasoning, then switch back |
| Repetitive bulk edits | /model haiku | Cheapest, fast enough |
| Working across a whole codebase | /model opus[1m] | 1M-token context window |
Frequently Asked Questions

Written by
InnovateTechie
Writing about Claude and the Anthropic toolkit — models, Claude Code, pricing, features, and fixes, in clear, practical, hands-on guides tested by daily use.
View all posts →




