Choose and switch models in Claude Code
Learn how to choose and switch Claude Code models, use aliases, context windows, and model commands effectively.
Lesson Content
Claude Code runs on LLM models supplied by Anthropic behind the scenes. When you start a new Claude Code session, it defaults to a specific model, but you're not just locked into that one model. You have your choice among all of Anthropic's frontier models, which includes Fable, Opus, Sonnet, and Haiku.
Breakdown of model names
You can switch a model by typing /model, and this will bring up the picker where you can select another model to use.
You can also type /model [modelName], such as /model sonnet, to switch to another model right away. Within the picker, you can choose a number, or select one and press Enter to switch models.
Here's a rundown of all of the model names and what they're all good at:
fableis the most intelligent model to date, and it’s built for work that needs the most mental power, so think highly-complex planning sessions, or those tasks that all of the models seem to struggle withopusis also a very intelligent model, that’s best for complex reasoning, defining larger architectural decisions, creating plans and laying out codebase refactors, and some more advanced bugs that sonnet can’t seem to catchsonnetis the workhorse model, which is great at handling nearly all of your coding tasks, and is where most of the day-to-day work actually happenshaikuis the small, fast model, which is great for simple changes, small scripts, or edits where speed is of the upmost importance, though it’s not that intelligent at solving problemsbestpicks the best model available in your account, currently Fable if your account has access to it, or Opus if it doesn'topusplanuses the Opus model while in plan mode, but then it switches over to Sonnet once it’s ready to execute the plan
It’s possible for Fable, Opus, Sonnet and Haiku to be on different major version release numbers, as they are each released at different times. The whole point of using aliases without these version names is so you don’t need to update everything every time a new model is released. You can just continue to use them as normal, and reap the benefits of the updated model.
What [1m] means
You'll also see opus[1m] and sonnet[1m] floating around, and this may confuse you a bit. Every model has a context window, which is how much of your conversation, your files, and its own work it can hold in mind at once. The bigger the window, the longer you can go before the session maxes out of tokens.
For a while, the large models ran a 200k token window by default, and a 1M token window was something you needed to opt into. That opt-in is what the [1m] suffix is. But it’s mostly history now. Fable, Sonnet, and Opus all run the one million token window on their own, so typing /model sonnet[1m] will get you the same model as typing /model sonnet.
So to sum it up, you can ignore the suffix. It’s still around just for those who use an older, pinned-down version of a model, or a company that routes Claude Code through a different infrastructure that needs these designations to know which model to run.
Pro note: While we're on the topic of context windows, running one of these 1M context windows actually doesn't cost any extra, so don’t hesitate to use them.
Switching models with a flag
Note that doing this also saves that choice as your default for every new session moving forward.
To apply a model change to just the current session, press the s key. This is useful if you want to toggle on a more intelligent model like Fable for a few prompts, and not make it the new permanent option moving forward.
You can also choose to launch a model right from the CLI with the --model flag:
claude --model haikuSwitch without losing your prompt
Here’s one other tip that many devs don’t know about. Let’s say that you’ve just typed out or are in the middle of typing out a long prompt, and then you just realized that you want to run it on Fable, but you’re on Haiku.
You’d need to clear out your prompt, or copy it to the clipboard, type /model to make your change, and then paste your prompt back back in. This is a huge hassle!
So instead, what you can do is press Option+P on macOS, or Alt+P on Windows and Linux. This will open the model switcher, where you can again select one with the s key, but this switches the model while retaining whatever you typed in the prompt.
Which model to choose
I recommend to probably use the opusplan option so you always use Opus for planning out tasks, which makes Sonnet execute the plan’s task. I’ve had very good success with this approach. I rarely use Haiku unless I want to dispatch many workers or subagents at once that each do a really simple thing, but usually Sonnet is plenty fast for carrying out most tasks. I will use Fable if I have a really complex plan or ask that I have a feeling Opus may struggle with, have a design that I’d like it to create, or when I just want the highest level of intelligence possible for a specific ask.
Beyond that, the model you pick matters a lot less than people think with any of these frontier models. How you prompt and chat with the agent is going to generally matter a lot more than antagonizing over which model to use.
Join the discussion!
Comments
Want to comment on this lesson?
Log in to leave comments.