πŸ“ Tutorials
Β· 4 min read

Claude Sonnet 5 in Claude Code: Setup, Config, and Cost Tips


Claude Sonnet 5 is available in Claude Code from launch day, and for most teams it is the right default. It delivers most of Opus 4.8’s agentic quality at less than half the cost. This guide shows how to set it up, switch models, tune effort, and avoid the cost traps.

If you are new to the tool, start with how to use Claude Code and keep the Claude Code cheat sheet handy.

Step 1: Update Claude Code

Make sure you are on a current version so Sonnet 5 appears as a model option:

npm install -g @anthropic-ai/claude-code
claude --version

Step 2: Select Sonnet 5 as your model

Inside a Claude Code session, open the model picker with the slash command:

/model

Choose Claude Sonnet 5 from the list. You can also set it as the session default through your Claude Code settings. The model string under the hood is claude-sonnet-5.

Step 3: Set effort levels

Sonnet 5 supports selectable reasoning effort: low, medium, high, max, and x-high. In Claude Code, use lower effort for routine edits and higher effort for complex, multi-file changes. Higher effort uses more tokens, so it is a direct cost lever. Our effort levels guide covers when each tier is worth it.

A practical default: run Sonnet 5 at low or medium effort for the bulk of work, and bump to high only when a task genuinely needs deeper reasoning.

Step 4: Know when to escalate to Opus 4.8

The smart pattern is a two-model workflow. Use Sonnet 5 for most coding, then switch to Opus 4.8 with /model for the hardest problems: deep debugging, large refactors, tricky architecture, and any reduced-guardrail security work that Anthropic recommends Opus for. This keeps your spend low without giving up the flagship when it matters. See Sonnet 5 vs Opus 4.8 for the decision rule, and migrate from Opus 4.8 to Sonnet 5 if you are moving spend down.

Step 5: Use the 1M context window wisely

Sonnet 5 supports a one million token context window, so Claude Code can load large parts of a codebase at once. That is powerful, but big context costs input tokens. Use focused file selection and let Claude Code pull in only what the task needs.

Cost tips for Claude Code

  • Default to lower effort levels and escalate per task.
  • Avoid maxing out effort on Sonnet 5 just to match Opus; at x-high it can cost more than Opus 4.8 at a comparable accuracy point.
  • Remember the new tokenizer can raise effective token counts by up to 1.35 times. See pricing explained.
  • Commit often so you can recover cheaply if an agentic run goes sideways.

A realistic two-model workflow

The most cost-effective way to run Claude Code in 2026 is to treat Sonnet 5 as your everyday driver and Opus 4.8 as the specialist you call in for hard problems. In practice that looks like this:

  1. Start your session on Sonnet 5 at medium effort.
  2. Do the bulk of the work, feature changes, tests, refactors, and routine debugging, on Sonnet 5.
  3. When you hit a genuinely hard problem, a subtle concurrency bug, a large cross-cutting refactor, or a tricky architecture decision, run /model and switch to Opus 4.8 for just that task.
  4. Switch back to Sonnet 5 when the hard part is done.

This pattern captures most of the cost savings of Sonnet 5 while keeping the flagship one command away. See Sonnet 5 vs Opus 4.8 for the full decision rule.

Troubleshooting common issues

  • Sonnet 5 does not appear in /model. Update Claude Code with npm install -g @anthropic-ai/claude-code and restart.
  • Permission errors when editing files. This is a Claude Code permissions issue, not a model issue. See the permission denied fix.
  • Sessions cost more than expected. Lower your default effort level, trim how many files enter context, and remember the new tokenizer can raise effective token counts by up to 1.35 times. See pricing explained.
  • A task keeps failing. Rather than retrying on Sonnet 5, escalate that task to Opus 4.8.

Tips for agentic runs

Sonnet 5 is strong at long, autonomous runs, but you stay in control. Commit frequently so you can roll back cheaply, give it clear and specific instructions, and review diffs before accepting large changes. For a broader command reference, keep the Claude Code cheat sheet open, and if you are deciding between editors, see Claude Code vs Cursor 2026.

Frequently asked questions

How do I switch to Sonnet 5 in Claude Code? Run /model in a session and select Claude Sonnet 5, or set it as the default in your settings.

Is Sonnet 5 the default model in Claude Code? It is the default for Free and Pro plans. You can still pick Opus 4.8 manually for harder tasks.

Can I use both Sonnet 5 and Opus 4.8 in the same project? Yes. Switch models mid-session with /model. A common pattern is Sonnet 5 for routine work, Opus 4.8 for the hard edges.

Does Sonnet 5 cost more in Claude Code than Sonnet 4.6? Introductory token pricing is lower, but the new tokenizer can raise effective costs. Model your real workload.

Does Sonnet 5 work with Claude Code plugins and skills? Yes. Sonnet 5 works with the standard Claude Code feature set. Selecting the model does not change how plugins, skills, or commands behave.

Will my existing Claude Code config keep working? Yes. Switching to Sonnet 5 is a model selection, not a config rewrite. Your existing settings, hooks, and project setup carry over.

The bottom line

Setting Sonnet 5 as your Claude Code default is the cheapest way to get near-flagship agentic coding. Run it at sensible effort levels, keep Opus 4.8 one /model command away for the hard problems, and mind the tokenizer when you budget. For the model details, read the complete guide.