/model.
This page covers how to:
- Set environment variables in your shell or in a settings file
- Check which value applies when a behavior can be set more than one way
- Look up the variables Claude Code reads
Set environment variables
A variable you set in your shell lasts for that terminal session, while a variable in a settings file applies every timeclaude runs.
In your shell
Set the variable before launchingclaude:
- macOS, Linux, WSL
- Windows PowerShell
- Windows CMD
export line to ~/.bashrc, ~/.zshrc, or your shell’s profile file.claude:
- macOS, Linux, WSL
- Windows PowerShell
- Windows CMD
In settings files
Add variables under theenv key in a settings.json file, creating the file if it doesn’t exist. Claude Code reads them directly from the file, so they take effect no matter how claude was launched. A running session applies new and changed values to its environment when you save the file, but a feature that reads its variables once at startup, such as OpenTelemetry monitoring, keeps its startup values until you relaunch. Removing a variable from the file doesn’t unset it in a running session; the removal takes effect the next time you launch claude.
~/.claude/settings.json
See Settings files for where each file lives and Settings precedence for how they combine when more than one sets the same variable.
Precedence
Some behaviors have both an environment variable and a dedicated settings key. If you set both, the environment variable takes precedence. For example,ANTHROPIC_MODEL overrides the model setting, and CLAUDE_CODE_AUTO_CONNECT_IDE overrides autoConnectIde. Claude Code uses the settings key only when the environment variable is unset.
When the same variable is set in both your shell and a settings file env block, the settings file value applies. Claude Code writes each env entry into the process environment at startup and again when the file changes, replacing the value inherited from the shell. A few variables are special-cased; the env setting lists the exceptions.
In a settings file you can set a variable but you can’t remove one. To override a variable you can’t unset, such as a stale CLAUDE_CODE_USE_VERTEX exported by a shell profile you don’t control, set it to an empty string in the env block: "CLAUDE_CODE_USE_VERTEX": "". Claude Code treats the empty value as unset for provider selection. Subprocesses still inherit the empty value.
Between settings files, env values follow settings precedence, so a managed settings entry overrides the same variable in user or project settings.
How an environment variable interacts with CLI flags and in-session commands varies per feature: --model and /model override ANTHROPIC_MODEL, while CLAUDE_CODE_EFFORT_LEVEL overrides /effort. When a variable interacts with another configuration source, its row in the Variables list states the precedence or links to the page that documents it.
Claude Code reads shell environment variables at startup, so changes to them take effect the next time you launch claude. Variables set under the env key in settings files are reapplied to a running session when the file changes, with the startup-only exception described in In settings files.
Variables
Numeric variables such as timeouts, token budgets, and retry counts accept scientific notation and digit-separator spellings in addition to plain digits, except where a variable’s row notes it takes plain digits only. For example, Claude Code reads2e3 as 2000 and 64_000 as 64000. Before v2.1.211, these spellings could silently set a much smaller value, such as 1e6 setting a timeout to 1.
For variables that turn a behavior on or off, set
1 or true to turn it on and 0 or false to turn it off, in any casing.Some variables read only whether you set them at all, so any non-empty value including 0 turns the behavior on, and you turn the behavior off by unsetting the variable or setting it to an empty value. These variables work that way:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICDISABLE_TELEMETRYDISABLE_ERROR_REPORTINGCLAUDE_CODE_TMUX_TRUECOLORFALLBACK_FOR_ALL_PRIMARY_MODELSIS_DEMO
FORCE_HYPERLINK reads a number, so only 0 turns it off. Each variable’s row also states its own rule.