Claude Code Model Configuration

Definition

How model selection works in Claude Code: aliases, the opusplan hybrid strategy, precedence chains, enterprise allowlists, and fallback mechanisms (captured 2026-07-31, HTTP 200).

Key Points

  • Aliases are version-sensitive and provider-dependentdefault, best, fable, sonnet, opus, haiku, opusplan, sonnet[1m], opus[1m]; the same alias resolves differently by provider (Anthropic API → Opus 5/Sonnet 5; Bedrock/GCP → Opus 5/Sonnet 4.5; Foundry → Opus 4.6/Sonnet 4.5). “Aliases point to the recommended version for your provider and update over time.” Pin by full name (claude-opus-5) or ANTHROPIC_DEFAULT_*_MODEL.
  • opusplanopus in plan mode, sonnet in execution mode; the plan-mode Opus phase inherits the opus context window (auto-upgraded to 1M on eligible tiers; force opusplan[1m]).
  • Precedence chain/model <alias> (Enter = save default, s = session-only) → claude --modelANTHROPIC_MODELmodel settings field; as of v2.1.153 /model writes the model field to user settings; resumed sessions keep the transcript’s model.
  • Enterprise governanceavailableModels allowlist + enforceAvailableModels + model/env pins; “The model setting is an initial selection, not enforcement.” Empty allowlist never locks out Default; keep ≥1 guaranteed-available entry. Org-level restrictions are enforced server-side, separate from availableModels.
  • Two fallback mechanisms — availability-based chains (cap 3, current-turn-only, entries outside the allowlist dropped, no fallback to smaller context during compaction) and content-based safety-classifier fallback for Fable 5/Opus 5 (switchModelsOnFlag, v2.1.219+).

Implications

Model selection is a token-spend lever: effort levels are explicitly framed as a token/capability tradeoff, and routing cheap models (Haiku) to background work cuts cost. The provider-dependent alias resolution means claims like “opus = Opus 5” are only true on some providers — a source of seeming contradiction to flag in citations. opusplan is the canonical hybrid of expensive-reasoning/cheap-execution, mirroring the plan-gate pattern at model level.

Open Questions

  • Heavily version-sensitive: dozens of “Before v2.1.x” gates (alias resolution v2.1.219, enforceAvailableModels v2.1.175, org defaults v2.1.196, --effort ultracode v2.1.203); deprecation: ANTHROPIC_SMALL_FAST_MODELANTHROPIC_DEFAULT_HAIKU_MODEL; merge→replace flip of managed availableModels at v2.1.175. All claims drift as versions move.
  • Model names (Opus 5, Sonnet 5, Fable 5) postdate the vault’s model entity pages.

claude-code-environment-variablesANTHROPIC_MODEL, ANTHROPIC_DEFAULT_*_MODEL, subagent/effort/context env vars llm-settings-and-parameters — effort levels, extended thinking, context window controls prompt-cachingDISABLE_PROMPT_CACHING{,_HAIKU,_SONNET,_OPUS,_FABLE} config claude-code-sessions — model persistence on resume, session-only vs saved /model token-usage-reduction — effort/model routing as a token-spend lever claude-code-best-practices — the workflow this configuration supports claude-code-context-window — 1M-token model gate this doc’s aliases resolve to

Sources

  • raw/external/code-claude-com-model-config-815ffab5.md