Skip to main content

Environment Variables

An environment variable is a named setting that a program reads when it starts. Claude Code 2.1.312 reads well over a thousand of them. This section lists 1458 variables that you can use. It splits them into groups, so you can find them. The official docs list a few of them. Only the program shows most of them.

Set a variable in your shell, or under the env key of ~/.claude/settings.json, .claude/settings.json, .claude/settings.local.json, or managed settings. To change a value, edit it, then restart claude. When the file changes, values in a settings env block also apply to a running session.

How Claude Code Reads Variables​

Claude Code starts with the environment it inherits from your shell. It then reads the env key of every settings file and writes each entry into its own process environment. Source: the official Environment Variables page.

A feature then reads the variable from the process environment. For some variables, a CLI flag or a settings key can win instead.

Which Value Wins​

  1. A value in a settings env block replaces the value from your shell in most sessions. The official docs list the sessions that keep the shell value.
  2. Between settings files, env values follow the normal settings order. A managed entry beats the same variable in user or project settings.
  3. Some behaviors have a variable, a settings key, and a flag. Which one wins differs for each pair. For example, --model and /model beat ANTHROPIC_MODEL, and ANTHROPIC_MODEL beats the model key. But CLAUDE_CODE_EFFORT_LEVEL beats --effort and /effort.
  4. Project and local settings cannot set some variables, such as CLAUDE_CONFIG_DIR and the OpenTelemetry exporter variables. Claude Code applies most other env values from a project only after you trust the folder.
  5. You cannot remove a variable from a settings file. To cancel one that a shell profile exports, set it to an empty string, for example "CLAUDE_CODE_USE_VERTEX": "". Claude Code treats the empty value as unset for provider selection, but child processes still inherit the empty value.

Each row says what applies to it. Look in the Notes column for the words "Project env can set it before trust" or "Not set from project env before trust".

Set Variables in settings.json​

Put variables under the env key. Claude Code copies the values as written. No shell expands them, so ~ and $HOME stay as typed. Use absolute paths.

~/.claude/settings.json
{
"$schema": "https://clawdipedia.cc/schemas/claude-code-settings.json",
"env": {
"API_TIMEOUT_MS": "1200000",
"BASH_DEFAULT_TIMEOUT_MS": "300000",
"CLAUDE_CODE_EFFORT_LEVEL": "high"
}
}

Alternatively, set one in your shell for one session.

export API_TIMEOUT_MS=1200000
claude

Removing a variable from the file does not unset it in a running session. The removal applies the next time you start claude. Features that read their variables only once at startup, such as OpenTelemetry, keep their startup values until you restart.

Numeric variables, such as timeouts and token budgets, accept forms like 2e3 (2000) and 64_000 (64000) as well as plain digits. A few rows say they take plain digits only.

Twenty Useful Variables​

VariablePageWhat it does
ANTHROPIC_API_KEYAuth and AccountsYour API key.
ANTHROPIC_BASE_URLNetwork and ProxySend API calls to another address.
ANTHROPIC_MODELModels and EffortThe model for the session.
ANTHROPIC_DEFAULT_SONNET_MODELModels and EffortThe model ID that the sonnet alias means.
CLAUDE_CODE_EFFORT_LEVELModels and EffortHow hard the model thinks. Wins over --effort and /effort.
CLAUDE_CODE_MAX_OUTPUT_TOKENSModels and EffortThe most output tokens for a request.
CLAUDE_CODE_USE_BEDROCKCloud ProvidersUse Amazon Bedrock.
CLAUDE_CODE_USE_VERTEXCloud ProvidersUse Google Vertex AI.
HTTPS_PROXYNetwork and ProxySend traffic through an HTTPS proxy.
NO_PROXYNetwork and ProxyHosts that skip the proxy.
API_TIMEOUT_MSNetwork and ProxyHow long an API request may take. Default is 600000.
BASH_DEFAULT_TIMEOUT_MSTools and BashDefault time limit of a foreground shell command.
BASH_MAX_OUTPUT_LENGTHTools and BashHow many characters of shell output Claude reads back.
CLAUDE_AUTOCOMPACT_PCT_OVERRIDEContext and CompactionStart compaction earlier.
CLAUDE_CONFIG_DIRSessions and StorageUse another folder instead of ~/.claude.
DISABLE_AUTOUPDATERSessions and StorageStop automatic background updates.
DISABLE_TELEMETRYTelemetry and DebugOpt out of telemetry. Any non-empty value counts.
CLAUDE_CODE_ENABLE_TELEMETRYTelemetry and DebugTurn on OpenTelemetry metrics and logs.
MCP_TIMEOUTPlugins and MCPHow long an MCP server gets to start.
CLAUDE_CODE_SIMPLEFeatures and TogglesRun a minimal mode. --bare sets it.

Variable Groups​

PageWhat is in itVariables
Models and EffortEnvironment variables that pick the model, pin model aliases, set thinking effort, and limit output size84
Auth and AccountsEnvironment variables for API keys, login tokens, credential helpers, and account details79
Cloud ProvidersEnvironment variables for Amazon Bedrock, Google Vertex AI, Microsoft Foundry, and gateway setups78
Network and ProxyEnvironment variables for API addresses, proxies, TLS certificates, time limits, and retries68
Context and CompactionEnvironment variables for the context window, compaction, memory, and the prompt cache49
Tools and BashEnvironment variables for the Bash tool, file tools, search, permissions, and the sandbox102
UI and TerminalEnvironment variables for the terminal screen, colors, voice, keys, and notifications88
Sessions and StorageEnvironment variables for config folders, session files, resume, install, and updates78
Telemetry and DebugEnvironment variables for usage data, OpenTelemetry, debug logs, and error reports141
Plugins and MCPEnvironment variables for plugins, MCP servers, skills, hooks, and marketplaces102
Agents and TeamsEnvironment variables for subagents, agent teams, background tasks, and workers80
Features and TogglesEnvironment variables that turn single features on or off, including server-gated features67
Remote and Cloud SessionsEnvironment variables for cloud sessions, the bridge, the desktop app, Chrome, Cowork, and Slack186
SDK and AutomationEnvironment variables for programs that host Claude Code, the Agent SDK, and automation25
System and Third-PartyEnvironment variables owned by your system or other tools that Claude Code reads, such as HOME, TERM, and ALL_PROXY130
Bundled LibrariesEnvironment variables read only by libraries bundled inside Claude Code, such as the AWS SDK, gRPC, and cloud detectors126

How to Read the Tables​

Every group page has the same columns.

ColumnMeaning
VariableThe exact name. Names are case sensitive.
StatusBadges.
Documented: An official docs page names this item.
means the official docs name it.
Undocumented: Only the program shows this item. It can change without notice.
means only the program shows it.
Differs: The official docs and the program disagree. The row says how.
means the docs and the program disagree.
Gated: Works only behind a flag or a server gate.
means a feature flag or server gate affects it.
What it doesThe effect, in plain words.
Values and defaultThe accepted values and the default, as far as the program shows. A dash means the source gave no detail.
NotesWhere it applies, and whether a project env block can set it before you trust the folder.
warning

Treat

Undocumented: Only the program shows this item. It can change without notice.
and
Gated: Works only behind a flag or a server gate.
rows with care. They work in 2.1.312, but nothing promises they will work in the next release.

Some rows mention a probe. That means a run of the real binary against a local stub showed what the variable changed in the request. No model call leaves the machine in a probe. A run with no visible effect does not prove that a variable does nothing.

What Is Left Out​

The tables list only variables you can use. They leave out removed or inert names, test-only names, names for Anthropic staff, and flags whose purpose nobody knows. For every item that only the program shows, see Undocumented Items.