Auto-Fallback to Another Model When Overloaded
Nothing kills a CI pipeline like a model being temporarily overloaded and your automated task failing silently. The --fallback-model flag tells Claude Code to automatically switch to a backup model if your primary one can't handle the request.
claude -p --fallback-model sonnet "Analyse this codebase for security vulnerabilities"
If the default model (say, Opus) is overloaded, Claude Code transparently retries with Sonnet instead of failing. Your script gets an answer either way.
You can pair it with --model to set both the primary and fallback explicitly:
# Try Opus first, fall back to Sonnet if overloaded
claude -p \
--model opus \
--fallback-model sonnet \
"Generate a comprehensive test suite for the auth module"
This is a print-mode-only flag, designed for automation scenarios where you'd rather get a slightly less powerful response than no response at all. In interactive sessions, you can switch models on the fly with /model instead.
For CI/CD pipelines, this single flag can be the difference between a green build and a blocked deploy queue. Combined with --max-budget-usd and --max-turns, you get a robust, cost-controlled, failure-resistant automation setup.
A fallback model is like a generator for your pipeline. You hope you never need it, but you're glad it's there.
Log in to leave a comment.
The autoUpdatesChannel setting pins Claude Code to a stable release track that skips versions with major regressions.
The language setting makes Claude respond in your preferred language by default, across every session and project.
The attribution setting lets you customize or completely remove Claude's Co-Authored-By trailer from git commits and pull requests.