Issue 00 · Autumn 2026日本語 · RSS
AgentKoji

Pinning the Claude Code Model in CI and settings.json

Pin the Claude Code model in CI with --model, ANTHROPIC_MODEL or settings.json, why aliases like opus drift, and what to fix before Opus 4.8 fast mode ends.

TL;DR

  • Claude Code picks the model from /model, then --model, then ANTHROPIC_MODEL, then the model setting, then ANTHROPIC_DEFAULT_MODEL. --model and ANTHROPIC_MODEL apply only to the session they launch.
  • Aliases such as opus and sonnet resolve to the recommended version for your provider and change over time; the docs list the Claude Code version at which each alias moved. To pin, use a full model name such as claude-opus-5-5.
  • Fast mode for Opus 4.8 was deprecated on 2026-10-30 and will be removed on 2026-11-30; after that the API rejects requests on Opus 4.8 with fast mode on. Switch to Opus 5.5 (v2.1.280+) or run /fast off.

If you run Claude Code in CI or cron jobs and never set a model, the job runs on whatever the default resolves to that day. This guide covers where Claude Code reads the model from, the difference between an alias and a full model name, how to pin in claude -p, GitHub Actions and settings.json, how organizations restrict models, and the fast mode change for Opus 4.8 due on November 30. Facts come from the official docs, checked 2026-11-03. On our machine we only confirmed that claude --help in Claude Code 2.1.317 lists --model, --fallback-model and --settings; we did not send requests to test the behavior below.

Where Claude Code reads the model from

In order of priority:

  1. /model <alias|name> during a session
  2. claude --model <alias|name> at startup
  3. The ANTHROPIC_MODEL environment variable
  4. The model field in a settings file
  5. ANTHROPIC_DEFAULT_MODEL, the default for new sessions (v2.1.236+)

--model and ANTHROPIC_MODEL apply only to the session you launch with them. /model in an interactive session saves your choice as the default by writing model to your user settings; in non-interactive mode (-p) it applies to that session only. A model in project or managed settings reapplies at every launch, and the startup header names the file that set it.

Claude Code doesn’t check a model set with --model, ANTHROPIC_MODEL or the model setting up front. A mistyped value produces “There’s an issue with the selected model” on the first request, so a typo in CI shows up as a failed job, not at startup.

Source: https://code.claude.com/docs/en/model-config (checked 2026-11-03)

Aliases drift, full names don’t

You can set the model to an alias or a full model name. On the Anthropic API, the aliases currently resolve like this:

AliasAnthropic APIAmazon Bedrock, Google Cloud’s Agent PlatformMicrosoft Foundry
opusOpus 5.5Opus 5.5Opus 4.6
sonnetSonnet 5.5Sonnet 4.5Sonnet 4.5
haikuHaiku 5.5Haiku 4.5Haiku 4.5

An alias points to the recommended version for your provider and updates over time. The docs keep a version history of when each alias moved, and it is tied to the Claude Code version: opus moved to Opus 4.8 at v2.1.154, to Opus 5 at v2.1.219 and to Opus 5.5 at v2.1.280 on the Anthropic API; sonnet moved to Sonnet 5 at v2.1.197 and to Sonnet 5.5 at v2.1.284; haiku moved to Haiku 5.5 at v2.1.293. So a CI job that installs the latest Claude Code and passes --model opus can change models when the CLI updates, with no change to your workflow file.

The default setting also moved. On Pro, Max, Ultra, Team, Enterprise and the Anthropic API it now resolves to Opus 5.5; before v2.1.280 it resolved to Sonnet 5 on Pro and Team Standard, and to Opus 5 on Max, Ultra, Team Premium, Enterprise and the Anthropic API.

To pin a version, use the full model name, for example claude-opus-5-5. Newer models also need a recent CLI: Opus 5.5 requires v2.1.280 or later, Sonnet 5.5 v2.1.284 or later, and Haiku 5.5 v2.1.293 or later.

When a requested model has a scheduled retirement date or is remapped to a newer version, Claude Code warns you and names the requested model. From v2.1.182, -p writes that warning to stderr with the default text output. It is suppressed for --output-format json and stream-json; read the model actually used from the modelUsage field of the result message instead.

Source: https://code.claude.com/docs/en/model-config (checked 2026-11-03)

Pin it in claude -p, GitHub Actions and settings.json

For a script or cron job, pass the full name on the command line:

claude -p "Summarize the failing tests in this log" --model claude-opus-5-5

Or set it once in the job’s environment. --model overrides ANTHROPIC_MODEL and the model setting:

export ANTHROPIC_MODEL=claude-opus-5-5
claude -p "Summarize the failing tests in this log"

In GitHub Actions, CLI flags go in claude_args. Without --model, the action uses Claude Code’s default model:

- uses: anthropics/claude-code-action@v1
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    prompt: "Generate a summary of yesterday's commits and open issues"
    claude_args: |
      --model claude-opus-5-5

To pin for everyone working in a repository, set model in the committed .claude/settings.json:

{
  "model": "claude-opus-5-5"
}

ANTHROPIC_MODEL in a shell applies over the model key from any settings file, and --model overrides both for a session.

Sources: https://code.claude.com/docs/en/cli-reference, https://code.claude.com/docs/en/github-actions and https://code.claude.com/docs/en/settings (checked 2026-11-03)

Pin what an alias resolves to

If your scripts or subagents use aliases, you can fix what each alias maps to with ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL. Each value must be a full model name or your provider’s equivalent ID. On Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry and Claude Platform on AWS, the docs tell you to pin these before rolling out, because the built-in default can lag the newest release or not yet be enabled in a user’s account. To move users to a new version, update the variables and redeploy.

# Amazon Bedrock example from the docs
export ANTHROPIC_DEFAULT_OPUS_MODEL='us.anthropic.claude-opus-4-8'

Source: https://code.claude.com/docs/en/model-config (checked 2026-11-03)

Fallback chains

--fallback-model takes a comma-separated list that Claude Code tries in order when the primary model is overloaded, unavailable or returns another non-retryable server error. Authentication, billing, rate-limit and request-size errors never trigger a switch. The switch lasts for the current turn, chains are capped at three models, and the flag overrides the fallbackModel setting:

claude -p "Run the release checklist" --model claude-opus-5-5 --fallback-model sonnet,haiku
{
  "fallbackModel": ["claude-sonnet-5", "claude-haiku-4-5"]
}

Claude Code doesn’t confirm the chain at startup, and /status doesn’t display it. The notice when a switch happens is the first sign a fallback is configured.

Source: https://code.claude.com/docs/en/model-config (checked 2026-11-03)

Restrict models for an organization

Administrators set these keys in managed settings:

A version-prefix entry such as claude-opus-5 also permits later releases that extend it, such as Opus 5.5, as soon as Claude Code supports them. That is the case deniedModels and "exact" exist for. Claude Code reads both of those keys from managed settings only.

{
  "availableModels": ["opus", "sonnet"],
  "deniedModels": ["claude-opus-5-5"]
}

For how settings files and managed settings rank, see Claude Code Permissions and settings.json: A Cheat Sheet.

Source: https://code.claude.com/docs/en/model-config (checked 2026-11-03)

Fast mode for Opus 4.8 is going away

Fast mode is a faster configuration of Claude Opus at a higher price per token. It is supported on Opus 5.5, Opus 5 and Opus 4.8. Fast mode for Opus 4.8 was deprecated on October 30, 2026, and will be removed on November 30, 2026. If Opus 4.8 is still your model with fast mode on after that date, the API rejects your requests. Before then, do one of these:

Fast mode costs $8 input and $40 output per million tokens on Opus 5.5, and $10 and $50 on Opus 5 and Opus 4.8. On Pro, Max, Ultra, Team and Enterprise it is paid from usage credits only, not from the plan’s included usage.

In CI, fast mode usually comes from settings rather than a toggle. /fast in -p works only in a session launched with fast mode in its --settings value, such as claude -p --settings '{"fastMode": true}', and an interactive /fast saves to the fastMode setting. To check a repository and its jobs:

# Where is fast mode turned on, and which model do the jobs pin?
grep -rn '"fastMode"' .claude/ ~/.claude/settings.json .github/workflows/ 2>/dev/null
grep -rn -E 'claude-opus-4-8|--model|ANTHROPIC_MODEL|ANTHROPIC_DEFAULT_OPUS_MODEL' .claude/ .github/workflows/ 2>/dev/null

Any job that combines fastMode: true with a pinned Opus 4.8 needs to move to claude-opus-5-5 or drop fast mode before November 30. Whether a job on the opus alias with an older Claude Code that still resolves opus to Opus 4.8 is affected the same way is not stated in the docs (unverified); updating the CLI to v2.1.280 or later moves opus to Opus 5.5.

Sources: https://code.claude.com/docs/en/fast-mode and https://code.claude.com/docs/en/model-config (checked 2026-11-03)

What we’d set in a CI job

These follow from the docs above; they are not results of a test on our side. For CI costs in general, see Running Claude Code in CI: Costs and Traps.

Summary

FAQ

How do I pin the model Claude Code uses in CI?
Pass a full model name with --model, for example claude -p --model claude-opus-5-5, or set ANTHROPIC_MODEL in the job's environment. In GitHub Actions, put --model in claude_args. Both apply only to the session they launch.
What is the difference between a model alias and a full model name?
An alias such as opus, sonnet or haiku resolves to the recommended version for your provider and updates over time. A full model name such as claude-opus-5-5 stays on that version. On the Anthropic API today, opus is Opus 5.5, sonnet is Sonnet 5.5 and haiku is Haiku 5.5.
What happens if I mistype the model name?
Claude Code doesn't check a model set with --model, ANTHROPIC_MODEL or the model setting up front. A mistyped value produces There's an issue with the selected model on the first request.
How do I keep the team on one model?
In managed settings, availableModels restricts which models users can select, and enforceAvailableModels: true extends the list to the Default option. deniedModels blocks specific models, and availableModelsMatch: "exact" makes each listed model ID permit only that version; both need Claude Code v2.1.283 or later.
What happens to fast mode on Opus 4.8?
It was deprecated on 2026-10-30 and will be removed on 2026-11-30. After that, a session still on Opus 4.8 with fast mode on gets its requests rejected by the API. Switch to Opus 5.5 with /model (v2.1.280+) to keep fast mode, or run /fast off to stay on Opus 4.8 at standard speed.