skip to content

A developer's Claude Code sessions keep starting on Sonnet at low effort despite /model opus and /effort high; their shell exports ANTHROPIC_MODEL and CLAUDE_CODE_EFFORT_LEVEL. What is happening?

level: seniorimportance: should knowfreq 7%

answer

  1. two ladders, opposite directions
  2. an environment variable in the profile
  3. /model beats it for one session
  4. the effort variable beats /effort
  5. header and /status confirm

basics

~10 s

Exported variables outrank the saved choices. ANTHROPIC_MODEL beats the model key /model saved, so each launch returns to Sonnet; CLAUDE_CODE_EFFORT_LEVEL outranks even /effort and --effort, so high never takes. Remove both from the profile.

solid answer

~40 s

Model and effort resolve through different orders. For the model, `/model` wins inside the session and writes `model` to `~/.claude/settings.json`, but at the next launch `ANTHROPIC_MODEL` outranks that saved key, so every session starts on Sonnet again. For effort, `CLAUDE_CODE_EFFORT_LEVEL` sits above `--effort` and `/effort`, so `/effort high` cannot override `low` even in the running session. The fix is to remove both exports from the shell profile; for a soft starting model use `ANTHROPIC_DEFAULT_MODEL`, which applies only when nothing else selects one, and for effort let `/effort` save a per-model level. The session header, which shows the model and "with low effort", confirms the result.

code

bash · 9 lines
bash
# Find variables that outrank saved choices
env | grep -E '^(ANTHROPIC_MODEL|CLAUDE_CODE_EFFORT_LEVEL|ANTHROPIC_DEFAULT_MODEL)='

# After deleting the exports from the shell profile:
unset ANTHROPIC_MODEL CLAUDE_CODE_EFFORT_LEVEL

# Optional: a starting model that a saved /model choice still outranks
export ANTHROPIC_DEFAULT_MODEL=opus
claude

go deeper

for a junior

Remember that an exported environment variable can quietly decide which model and effort a session starts with, whatever you chose last time.

for a middle

Lay out both precedence orders and point out that ANTHROPIC_MODEL sits below /model and --model, while CLAUDE_CODE_EFFORT_LEVEL sits above /effort and --effort.

for a senior

Work the diagnosis in order: header, environment, project or managed model value, resume, read-only settings, legacy effortLevel, caps. Fix the cause rather than re-typing the command.

for a principal

Decide which knobs a team standardizes: a soft starting model through ANTHROPIC_DEFAULT_MODEL, hard limits through caps, and no profile-level exports that silently override people.

## Two precedence ladders that point different ways Claude Code resolves the model and the effort level separately, and the environment variable sits at opposite ends of the two: | Rank | Model | Effort | |---|---|---| | 1 | `/model` in the session | `CLAUDE_CODE_EFFORT_LEVEL` | | 2 | `--model` at launch | `--effort` or `/effort`, the explicit choices | | 3 | `ANTHROPIC_MODEL` | the level saved for the model under `modelSettings`, or an `effortLevel` key | | 4 | the `model` setting | the model's own default | | 5 | `ANTHROPIC_DEFAULT_MODEL` | | For the model, in-session and launch choices beat the environment. For effort, the environment beats everything you type. A `maxEffortLevel` cap, where one is set, still limits whatever level wins. ## Walking through the scenario 1. **Launch.** `ANTHROPIC_MODEL=sonnet` outranks the `model` key in settings, so the session starts on Sonnet. 2. **`/model opus`.** An in-session switch has the highest model priority, so the session moves to Opus, and Claude Code writes `"model": "opus"` to `~/.claude/settings.json`. 3. **Next launch.** `ANTHROPIC_MODEL` is still exported and still outranks the saved key, so the session is back on Sonnet. The saved choice exists; it is outranked. 4. **`/effort high`.** `CLAUDE_CODE_EFFORT_LEVEL=low` outranks `/effort`, so the level stays `low` even in the current session. Nothing is broken. Both variables are doing what they are documented to do. ## The fix - Remove `ANTHROPIC_MODEL` and `CLAUDE_CODE_EFFORT_LEVEL` from the shell profile and open a new shell. - If the developer wants a starting model that `/model` can still replace, use `ANTHROPIC_DEFAULT_MODEL`: Claude Code uses it only when no `--model`, `ANTHROPIC_MODEL`, settings `model` value or organization default selects one. It ignores the variable when set to `default`, `inherit`, `opusplan` or `haiku`. - For effort, let `/effort` save a level per model, or keep the variable but set it to `auto` so the model default applies. ## Other reasons a model choice does not stick - **Session-only paths.** `s` in the `/model` picker, `--model`, and `/model` inside a `claude -p` run all leave the saved default alone. - **A higher source.** A `model` value in project or managed settings, or an organization default model configured to override user selection, reapplies at every launch; the startup header names the settings file when settings chose the model. - **An unwritable settings file.** If `~/.claude/settings.json` is generated by another tool or linked read-only, the choice lasts only for the session. - **Resume.** `claude --resume` and `--continue` usually restore the model the transcript was saved with. ## Other reasons an effort choice does not stick - **The legacy key.** Since v2.1.251, `/effort` saves levels per model under `modelSettings`. A top-level `effortLevel` in `~/.claude/settings.json` is the older form and keeps applying only to Opus 5, Fable 5.1 and earlier models; Opus 5.5 and later ignore it and start at their own default. In project, local or managed settings, the same key applies to every model. - **`max` is session-only.** Unless it comes from `CLAUDE_CODE_EFFORT_LEVEL`, `max` is never saved, and neither settings key accepts it. - **A cap.** `maxEffortLevel`, set in any scope, runs anything higher at the cap, including the environment variable and the model's default. - **Frontmatter.** A skill's or subagent's `effort` overrides the session level while it is active, though not the environment variable. - **Non-interactive runs.** `/effort` in a `-p` run applies to that session only. ## Confirming the diagnosis The session header shows the active model and the effort next to it ("with low effort"), and `/status` shows the model with account details. Checking the shell's environment for `ANTHROPIC_MODEL` and `CLAUDE_CODE_EFFORT_LEVEL` usually ends the investigation in one command. ## When the variables are the right tool The asymmetry is deliberate rather than a trap. Each variable has a place: - `ANTHROPIC_MODEL` fits a **wrapper script or a one-off shell** that should start on a particular model without touching anyone's saved default, while still letting the person at the keyboard switch with `/model`. - `CLAUDE_CODE_EFFORT_LEVEL` fits **scripts and automation** that must run at a known level no matter what a developer saved or types; it is also the only way to make `max` stick beyond one session. - Neither belongs in a personal shell profile unless the developer really wants every launch forced, which is exactly the situation that produced this report.

  • The developer sets "effortLevel": "high" in ~/.claude/settings.json, yet Opus 5.5 still runs at medium. Why?
    In user settings, top-level `effortLevel` is the legacy form `/effort` wrote before v2.1.251, when levels became per model under `modelSettings`. It still applies to Opus 5, Fable 5.1 and earlier models, but Opus 5.5 and later ignore it and use their own default until a level is saved for them. Running `/effort high` on Opus 5.5 saves it correctly.
  • The team wants nobody running above high, whatever they type. Which control fits?
    `maxEffortLevel`: any higher level, from `/effort`, `--effort`, `CLAUDE_CODE_EFFORT_LEVEL`, frontmatter or the model default, runs at the cap, and Claude Code enforces it on every provider. When several scopes set a cap, the lowest wins. Setting `effortLevel` in managed settings is not enough, because users can still change it with `/effort`.

  • In-session commands always beat environment variables, for effort too
  • /model saves your choice, so the next launch always uses it
  • A top-level effortLevel in user settings applies to every model
  • Managed effortLevel stops users raising effort with /effort
  • Claude Code is ignoring the settings file, so reinstall it

Assumes Claude Code 2.1.286: /effort saves per-model levels under modelSettings since v2.1.251, and Opus 5.5 ignores a top-level effortLevel in user settings.