`--model` CLI flag silently ignored when ~/.claude/settings.json has a model key

Resolved 💬 3 comments Opened Mar 6, 2026 by johnrtipton Closed Mar 9, 2026

Summary

When ~/.claude/settings.json contains a "model" key, the --model CLI flag is silently ignored. The settings.json model takes priority, which is the opposite of the documented precedence order.

Documented behavior

From the settings documentation, the precedence order (highest to lowest) is:

  1. Managed policy
  2. Command line args (--model)
  3. Local (.claude/settings.local.json)
  4. Project (.claude/settings.json)
  5. User (~/.claude/settings.json) — lowest

Actual behavior

~/.claude/settings.json overrides --model. The CLI flag is accepted without error but has no effect.

Reproduction

# 1. Set model in global settings
# (or use /model in any session, which writes to settings.json)
cat ~/.claude/settings.json | jq '.model'
# => "claude-opus-4-6"

# 2. Run with --model specifying a different model
claude --model claude-sonnet-4-6 -p "What model are you?" --output-format stream-json

# 3. Check the init event in the output
# Expected: "model": "claude-sonnet-4-6"
# Actual:   "model": "claude-opus-4-6"

Additional note: /model writes globally

The /model slash command updates ~/.claude/settings.json, which affects all sessions — not just the current one. Combined with the priority bug above, changing your model in one interactive session silently changes the model for every other running or future session, including programmatically spawned agents using --model.

Impact

We run an orchestrator that spawns Claude Code agents with --model claude-sonnet-4-6. Because ~/.claude/settings.json had "model": "claude-opus-4-6" (set via /model in an interactive session), every spawned agent silently used Opus instead of Sonnet. This went undetected because:

  • The --model flag was accepted without warning
  • The agent's system/init JSON event showed the actual model (claude-opus-4-6), but the caller had no reason to check — it trusted the flag it passed
  • The result was ~330 agents running on Opus in 5 hours, exhausting the 5-hour rate limit

Suggested fix

  1. Primary: --model CLI flag should override settings.json, matching the documented precedence
  2. Nice to have: /model should only affect the current session, not write to the global settings.json (or offer a --session-only option)
  3. Nice to have: If --model is passed but overridden by settings, emit a warning in the output stream

Workaround

Setting the ANTHROPIC_MODEL environment variable before spawning appears to work as an override, but it's unclear where this falls in the documented precedence order.

Environment

  • Claude Code version: 2.1.70
  • Platform: macOS (Darwin 25.3.0)
  • Auth: OAuth

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗