Setting the Default Model in the VS Code Claude Code Extension

Spent way too long figuring out why the VS Code extension keeps defaulting to Sonnet 5 despite having the model set in Claude Code's settings. Here's what's going on and what actually fixes it.

The Problem

The VS Code extension keeps defaulting to Sonnet 5 on every new session, even with "model": "claude-sonnet-4-6" set in ~/.claude/settings.json. Multiple open GitHub issues on this going back to late 2025, no official fix yet.

I tried all of these and none of them worked:

  • Setting "model": "claude-sonnet-4-6" in ~/.claude/settings.json
  • Setting "claudeCode.selectedModel" in VS Code's own settings.json
  • Using claudeCode.environmentVariables with ANTHROPIC_MODEL
  • Changing the model via the extension's dropdown picker

What Worked

Adding the model as an environment variable directly in the shell profile. For zsh on Mac:

export ANTHROPIC_MODEL=claude-sonnet-4-6

Drop that into ~/.zshrc, run source ~/.zshrc, then fully quit VS Code with Cmd+Q and reopen. The extension picks it up on launch and respects it consistently.

Why Does This Happen?

The VS Code extension and the terminal claude command are essentially two separate things, even though they're both part of Claude Code. The CLI reads from ~/.claude/settings.json correctly and respects the model key without any issues. The VS Code extension, however, bundles its own Claude Code binary and manages its model state completely independently.

This means that when a new session starts in the extension, it spins up its own process with its own hardcoded defaults — and those defaults override whatever is set in the config files. It doesn't matter how many places the model is configured, the extension's internal state wins every time.

Setting ANTHROPIC_MODEL at the shell level sidesteps this entirely. Environment variables get picked up at launch, before the extension's internal logic runs, which is why it's the one thing that actually sticks.