Every environment variable Claude Code reads, grouped by purpose, with how to set them, how they interact with settings, and which ones disable feature flags.
Environment variables are the lowest-level way to change how Claude Code behaves: which provider and model it talks to, how long it waits, what it logs, which features are switched on. Many of the same knobs also exist as settings, CLI flags or in-session commands, and this page tells you which wins when they disagree.
The reference is grouped by purpose rather than alphabetically, because you are usually trying to solve one problem at a time. Use your browser's find to jump to a specific name.
Setting a variable
In your shell
A shell variable lasts for that terminal session. Set it before launching:
export API_TIMEOUT_MS=900000
claude
$env:API_TIMEOUT_MS = "900000"
claude
set API_TIMEOUT_MS=900000
claude
To make it permanent, add the export to ~/.zshrc or ~/.bashrc; on Windows use [Environment]::SetEnvironmentVariable("API_TIMEOUT_MS", "900000", "User") in PowerShell or setx API_TIMEOUT_MS "900000" in CMD, then open a new terminal. Check it with echo $API_TIMEOUT_MS, echo $env:API_TIMEOUT_MS or echo %API_TIMEOUT_MS%.
In a settings file
Put variables under env in a settings file and they apply every time claude runs, however it was launched:
Values are copied literally; no shell expands them, so ~ and $HOME stay as typed. Use absolute paths, e.g. "CLAUDE_CONFIG_DIR": "/Users/cam/.claude-clients".
Which file you choose decides who is affected:
File
Applies to
~/.claude/settings.json
You, everywhere
.claude/settings.json
Everyone on the project (committed)
.claude/settings.local.json
You, in this project (git-ignored when Claude Code writes it; ignore it yourself if you create it by hand)
Managed settings
Everyone in the organisation
A running session picks up new and changed env values when the file is saved, except for features that read their variables once at start-up (OpenTelemetry, for example). Removing a variable from the file does not unset it in a running session; that happens at next launch. See Settings for file locations and precedence.
Which value wins
Variable versus setting. It depends on the pair. ANTHROPIC_MODEL and CLAUDE_CODE_AUTO_CONNECT_IDE are read before the model and autoConnectIde settings. Check each variable's entry below and the key's entry in the settings reference.
Shell versus settings env. In most sessions the settings file wins, because Claude Code writes each env entry into its process environment over the inherited value. A handful of variables are special-cased; the settings reference lists them.
Removing a shell variable from settings. You cannot unset a variable from a settings file, but an empty string counts as unset for provider selection: "CLAUDE_CODE_USE_VERTEX": "" neutralises a stale export from a profile you do not control. Subprocesses still inherit the empty value.
Between settings files, normal settings precedence applies, so managed beats user and project. Project and local settings cannot set some variables at all, such as CLAUDE_CONFIG_DIR and the OpenTelemetry exporter variables.
Versus flags and commands, it varies: --model and /model beat ANTHROPIC_MODEL, but CLAUDE_CODE_EFFORT_LEVEL beats --effort and /effort. Entries below say so where it matters.
Timing. Shell variables are read at start-up; settings env values are re-applied when the file changes (with the start-up-only exceptions above).
Value formats
Numbers accept scientific notation and digit separators, so 2e3 means 2000 and 64_000 means 64000, unless an entry says plain digits only. (Before v2.1.211, these spellings could silently produce tiny values.)
On/off variables accept 1, true, yes, on and 0, false, no, off, in any case.
Presence-only variables treat any non-empty value, including 0 and false, as on. Unset them (or set them empty) to turn them off. These are CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC, DISABLE_TELEMETRY, DISABLE_ERROR_REPORTING, CLAUDE_CODE_TMUX_TRUECOLOR, FALLBACK_FOR_ALL_PRIMARY_MODELS and IS_DEMO.
FORCE_HYPERLINK is read as a number, so only 0 turns it off.
Warning: The presence-only rule catches people out. DISABLE_TELEMETRY=0 still disables telemetry.
Authentication
Variable
Purpose
ANTHROPIC_API_KEY
API key sent as X-Api-Key. Used instead of your subscription even when signed in. Always used in -p; interactively you approve it once. unset it to go back to your subscription
ANTHROPIC_AUTH_TOKEN
Value for the Authorization header, prefixed with Bearer
ANTHROPIC_PROFILE
Named Anthropic profile to authenticate with, e.g. one from ant auth login or a Console sign-in without a key. See Authentication
Workspace to target when a federation rule spans several workspaces
CLAUDE_CODE_OAUTH_TOKEN
claude.ai OAuth access token for SDK and automation, from claude setup-token. Beats keychain credentials and lasts the whole session unless you /login; restart with a new token when it expires
CLAUDE_CODE_OAUTH_REFRESH_TOKEN
Refresh token that claude auth login exchanges without a browser. Needs CLAUDE_CODE_OAUTH_SCOPES
CLAUDE_CODE_OAUTH_SCOPES
Space-separated scopes the refresh token was issued with, e.g. "user:profile user:inference user:sessions:claude_code"
CLAUDE_CODE_API_KEY_HELPER_TTL_MS
How often to refresh credentials from apiKeyHelper
CLAUDE_CODE_DISABLE_AUTH_REFRESH_LOCK
1 makes each process run gcpAuthRefresh/awsAuthRefresh itself rather than waiting for another (v2.1.286)
Route API requests through a proxy or gateway. For non-first-party hosts, MCP tool search is off by default (set ENABLE_TOOL_SEARCH=true if your proxy forwards tool_reference blocks), and Remote Control is disabled (v2.1.196). See LLM gateway
CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST
Set by platforms embedding Claude Code that own provider routing. Settings-file provider, endpoint and auth variables are ignored; managed model-selection keys and managed env model variables are ignored (an availableModels allowlist still applies unless the host supplies one); and the automatic telemetry opt-out on third-party providers is skipped
Amazon Bedrock and Mantle
Variable
Purpose
AWS_BEARER_TOKEN_BEDROCK
Bedrock API key
ANTHROPIC_BEDROCK_BASE_URL
Custom Bedrock endpoint or gateway
ANTHROPIC_BEDROCK_MANTLE_BASE_URL
Custom Mantle endpoint
ANTHROPIC_BEDROCK_REGION_PREFIX
Cross-region inference prefix to try first: us, eu, apac, jp, au or global. Ignored in GovCloud (v2.1.224)
ANTHROPIC_BEDROCK_SERVICE_TIER
default, flex or priority, sent as X-Amzn-Bedrock-Service-Tier
ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION
Region for the Haiku-class background model on Bedrock or Mantle. On Bedrock it only applies when ANTHROPIC_DEFAULT_HAIKU_MODEL (or the deprecated ANTHROPIC_SMALL_FAST_MODEL) is set
CLAUDE_CODE_SKIP_BEDROCK_AUTH
Skip AWS auth, e.g. behind a gateway
CLAUDE_CODE_SKIP_MANTLE_AUTH
Skip AWS auth for Mantle
CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS
How long the AWS default credential chain may take before failing (default 60000); raise for SSO with MFA via tools like aws-vault. Also for Claude Platform on AWS and Mantle (v2.1.207)
CLAUDE_CODE_SKIP_AWS_CRED_CACHE
1 resolves the AWS chain on every request instead of caching (v2.1.207)
CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_GUARD
Skip the check that streams arrive as application/vnd.amazon.eventstream. Better to fix the gateway (v2.1.208)
CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_DEFAULT
Stop treating header-less Bedrock streams as event streams; only for gateways that re-emit as server-sent events (v2.1.239)
CLAUDE_ENABLE_BYTE_WATCHDOG_BEDROCK
1 enables the byte-level idle watchdog and first-byte deadline on Bedrock streams
Skip client-side auth for gateways that sign requests themselves
Request shaping for gateways
Variable
Purpose
ANTHROPIC_CUSTOM_HEADERS
Extra headers, Name: Value, newline-separated. Invalid characters (curly quotes, zero-width spaces) fail the request naming the pair (v2.1.227). Credential, tenant, routing or behaviour headers delivered by server-managed settings need approval
ANTHROPIC_BETAS
Extra anthropic-beta values, comma-separated; unlike --betas, works with any auth method
CLAUDE_CODE_EXTRA_BODY
JSON merged into the top level of every request body. Shell exports also reach background sessions (v2.1.206)
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS
Strip pre-release beta headers, their paired body fields, and beta tool-schema fields like defer_loading; fixes Unexpected value(s) or Extra inputs are not permitted errors. Also disables MCP tool search. See LLM gateway protocol
CLAUDE_CODE_DISABLE_STRUCTURED_OUTPUTS
Stop sending output_config.format and its beta, leaving other betas on (v2.1.288)
CLAUDE_CODE_DISABLE_THINKING
Omit the thinking parameter for proxies that reject it. Models that think by default may still think
DISABLE_INTERLEAVED_THINKING
Do not send the interleaved-thinking beta header
CLAUDE_CODE_ALWAYS_ENABLE_EFFORT
Send effort even for unrecognised model ids (models that reject it at the API are still excluded)
CLAUDE_CODE_ATTRIBUTION_HEADER
0 omits the attribution block (client version and prompt fingerprint) from the system prompt; direct API caching is unaffected. Some direct auto mode classifier requests keep it
CLAUDE_CODE_GATEWAY_HINT_HEADERS
1 sends hint headers such as x-claude-code-request-class to custom proxies and third-party providers; 0 stops them everywhere, including direct API connections where they are on by default (v2.1.273)
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY
1 fills the /model picker from the gateway's /v1/models. Off by default because a shared key would show everyone everything; filter with availableModels from MDM or a managed file
CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY_TIMEOUT_MS
Timeout for that discovery call (default 3000; plain digits) (v2.1.269)
CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING
Stream tool inputs as generated. On for the Anthropic API, per-model on Bedrock and Agent Platform, off on Foundry and gateways. 0 opts out; 1 forces it through a proxy
CLAUDE_CODE_PROPAGATE_TRACEPARENT
1 propagates W3C trace context (the traceparent header and TRACEPARENT for subprocesses) through a custom proxy; by default only direct connections propagate
Models
Variable
Purpose
ANTHROPIC_MODEL
Model to use. Beats the model setting; loses to --model and /model. See Model configuration
ANTHROPIC_DEFAULT_MODEL
Model new sessions start on (v2.1.236)
ANTHROPIC_DEFAULT_OPUS_MODEL
What opus resolves to; also opusplan in plan mode
ANTHROPIC_DEFAULT_SONNET_MODEL
What sonnet resolves to; also opusplan outside plan mode
ANTHROPIC_DEFAULT_HAIKU_MODEL
What haiku resolves to; also used for background work
ANTHROPIC_DEFAULT_FABLE_MODEL
What fable resolves to, and recognised as a Fable model for automatic fallback on third-party providers
Deprecated name for the Haiku-class background model
CLAUDE_CODE_SUBAGENT_MODEL
Default model for subagents, teammates and workflow agents not otherwise assigned one. A model Claude passes at spawn time and a definition's model (including inherit) still win. inherit equals unset
CLAUDE_CODE_SUBAGENT_MODEL_FORCE
1 forces one model on all of them (v2.1.257). See Subagents
CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP
Stop remapping Opus 4.0 and 4.1 to the current Opus on the Anthropic API
CLAUDE_CODE_DISABLE_MODEL_ACCESS_FALLBACK
On Bedrock and Agent Platform, fail immediately when access to the session's model is lost mid-session instead of switching to an older model. Configured fallback chains still apply (v2.1.285)
CLAUDE_CODE_SKIP_MODEL_ACCESS_MEMORY
Forget which models the start-up checks found unavailable (normally remembered for up to a day) (v2.1.285)
CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK
Turn off the automatic model switch when a safety classifier flags a request (the switchModelsOnFlag behaviour)
FALLBACK_FOR_ALL_PRIMARY_MODELS
Presence-only. Stop retrying on repeated overloads for every model when no fallback is configured (by default only Opus, Fable and Mythos models on API keys or third-party providers). Configured fallback chains already switch for any model
Thinking, effort, output and context
Variable
Purpose
CLAUDE_CODE_EFFORT_LEVEL
low, medium, high, xhigh, max or auto. Beats --effort, /effort, modelSettings and effortLevel; maxEffortLevel still caps it
MAX_THINKING_TOKENS
Fixed thinking budget, capped one below max output tokens and never under 1,024. 0 disables thinking on the Anthropic API (not on Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable, which always think; on third-party providers 0 omits the parameter). With thinking off, effort is sent as high to models that reject higher combinations. Positive values are ignored by adaptive models unless adaptive is disabled
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING
Use the fixed budget instead of adaptive reasoning on Opus 4.6 and Sonnet 4.6; no effect on newer models
CLAUDE_CODE_MAX_OUTPUT_TOKENS
Max output tokens for most requests; values above a model's cap are lowered. Unknown models default to 32000, cap 128000. Higher values shrink the space before auto-compaction
CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS
Raise the token limit for file reads
CLAUDE_CODE_DISABLE_1M_CONTEXT
Hide 1M variants and hold native-1M models (Sonnet 5.5, Fable) to 200K
CLAUDE_CODE_MAX_CONTEXT_TOKENS
Correct the assumed context window for a model id, e.g. a gateway alias. See Model configuration
Skip proactive compaction for unrecognised model ids (v2.1.223)
CLAUDE_CODE_AUTO_COMPACT_WINDOW
Auto-compact window in tokens, 100000 to 1000000, plain integer only (500k reads as 500 and clamps up). Capped at the model window; beats /autocompact, --autocompact and autoCompactWindow. The status line used_percentage still measures the full window
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE
Trigger compaction earlier, at this percentage (1 to 100) of the window; cannot raise the threshold. Applies to main conversations and subagents
DISABLE_AUTO_COMPACT
Turn off auto-compaction; /compact still works. Beats autoCompactEnabled
DISABLE_COMPACT
Turn off all compaction, manual included
CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT
1 uses the shorter system prompt on any model; 0 forces the full one. Unset, Haiku 4.5, Sonnet 5, Opus 4.7 and earlier get the full prompt and newer models the short one. Tools, hooks, MCP and CLAUDE.md are unaffected
MAX_STRUCTURED_OUTPUT_RETRIES
Attempts allowed for --json-schema output (and workflow subagent structured output) before failing; default 5
SLASH_COMMAND_TOOL_CHAR_BUDGET
Character budget for skill metadata shown to the Skill tool; default 1% of the context window, fallback 8,000
Request the 1-hour TTL. Aimed at API key and cloud-provider users; subscribers within included usage already get it on the main conversation, and those on usage credits can set it to keep it. 1-hour writes cost more
ENABLE_PROMPT_CACHING_1H_BEDROCK
Deprecated; use the above
CLAUDE_CODE_PROMPT_CACHE_TTL
5m or 1h for the main conversation; beats promptCacheTtl and ENABLE_PROMPT_CACHING_1H (v2.1.242)
CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL
5m or 1h for subagents, workflows and background work; beats subagentPromptCacheTtl (v2.1.242)
FORCE_PROMPT_CACHING_5M
Force 5 minutes, overriding all of the above
CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS
How long workflow agents sharing a cache prefix wait for the first to warm it (default 5000; 0 disables; never waits when caching is off) (v2.1.229)
CA sources: bundled (Mozilla set shipped with Claude Code), system (OS store, on runtimes with tls.getCACertificates). Default bundled,system. See Network configuration
Do not re-read rotated mTLS files after connection-level errors (v2.1.232)
CLAUDE_CODE_GZIP_REQUEST_BODIES
0 turns off gzip of large API, telemetry and artifact request bodies on direct connections (already skipped through proxies, client certs or NODE_EXTRA_CA_CERTS); use for undetected TLS-inspecting proxies
API_TIMEOUT_MS
Per-request timeout; default 600000 (10 minutes), max 2147483647 (higher overflows and fails instantly)
API_FORCE_IDLE_TIMEOUT
The 5-minute body idle timeout. 0 disables it (for slow gateways or local models), 1 forces it everywhere. Unset, it is active except on the direct API, Claude Platform on AWS, and Bedrock with the byte watchdog on
CLAUDE_CODE_MAX_RETRIES
Retries for failed requests (default 10, capped at 15 unless the retry watchdog is on)
CLAUDE_CODE_RETRY_WATCHDOG
For unattended work: retry 429 and 529 capacity errors indefinitely with up to 5-minute backoff (or until the reported reset), raise other transient retries to 300 (about three hours), and lift the cap on CLAUDE_CODE_MAX_RETRIES. Spend-limit and exhausted-credit 429s still fail at once (v2.1.186; v2.1.239 for the spend-limit change)
CLAUDE_CODE_NONSTREAMING_TIMEOUT_RETRIES
Cap re-sends of timed-out non-streaming requests; 0 fails on the first (v2.1.285)
CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK
Do not fall back to non-streaming when a stream fails mid-way; useful when a proxy makes the fallback duplicate tool runs
CLAUDE_ENABLE_STREAM_WATCHDOG
0/1 to force the event-level idle watchdog off or on (on by default for all providers)
CLAUDE_ENABLE_BYTE_WATCHDOG
0/1 to force the byte-level watchdog; 0 also disables the first-byte deadline. Default on for the direct API, Claude Platform on AWS and gateway streams
CLAUDE_STREAM_IDLE_TIMEOUT_MS
Idle timeout for both watchdogs; explicit values below 300000 are raised to it, and the byte watchdog caps at 30 minutes
CLAUDE_BYTE_STREAM_IDLE_TIMEOUT_MS
Byte-watchdog-only timeout, clamped to 10 seconds to 30 minutes (v2.1.210)
CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS
Deadline for the first byte of a streaming response where that deadline runs (v2.1.242). See Errors
CLAUDE_ASYNC_AGENT_STALL_TIMEOUT_MS
Stall timeout for subagents (default 600000), reset by each progress event; rises with a raised stream idle timeout
CLAUDE_CODE_CONNECT_TIMEOUT_MS
Removed in v2.1.186; no effect
Shell, tools and files
Variable
Purpose
BASH_DEFAULT_TIMEOUT_MS
Default foreground Bash/PowerShell timeout (120000). Above 30 minutes it also becomes the background time limit default in unattended sessions
BASH_MAX_TIMEOUT_MS
Highest timeout Claude may request (600000); the ceiling is the larger of this and the default. Above 2 hours it also raises the background maximum
BASH_MAX_OUTPUT_LENGTH
Characters of output read back (default 30000, max 150000); ignored if bashOutputMaxChars is set. See Tools reference
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR
Return to the project directory after every Bash or PowerShell command
CLAUDE_ENV_FILE
Script sourced before each Bash command, for persistent exports such as virtualenv activation; also filled by SessionStart, Setup, CwdChanged and FileChanged hooks
CLAUDE_CODE_SHELL
Path to the bash or zsh used for Bash commands; anything else falls back to auto-detection (your $SHELL if bash or zsh, else the first zsh then bash found)
CLAUDE_CODE_SHELL_PREFIX
Wrapper for Bash calls, hook commands, status line commands and stdio MCP start commands (not PowerShell or exec-form hooks). It receives the full command as one quoted argument in $1, so re-evaluate it, e.g. exec bash -c "$1"
CLAUDE_CODE_GIT_BASH_PATH
Windows: path to bash.exe if not on PATH. Invalid paths or names are ignored with a debug warning
CLAUDE_CODE_USE_POWERSHELL_TOOL
Control the PowerShell tool; see Tools reference for per-platform defaults
CLAUDE_CODE_POWERSHELL_RESPECT_EXECUTION_POLICY
Do not pass -ExecutionPolicy Bypass; honour the machine policy
CLAUDE_CODE_DISABLE_WINDOWS_SHELL_LAUNCHER
Start PowerShell commands directly rather than through cmd.exe; backgrounded PowerShell commands then stop when the process exits (v2.1.269)
CLAUDE_CODE_BASH_EDIT_DIFF
0 turns off the diff of files changed during a Bash command; 1 records it in every mode. Beats bashEditDiffEnabled (v2.1.269)
CLAUDE_CODE_TOOL_MEMORY_LIMIT
Linux/WSL memory cap for Bash, PowerShell and Monitor commands, e.g. 4G; 0 or off disables (v2.1.233)
CLAUDE_CODE_TOOL_MEMORY_CGROUP_EXCLUDE
Process kinds exempt from that cap: mcp, lsp, hooks, plugin, helper, agent; none or all-new (v2.1.246)
CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY
Read-only tools and subagents run in parallel (default 10)
CLAUDE_CODE_GLOB_HIDDEN
false excludes dotfiles from Glob results
CLAUDE_CODE_GLOB_NO_IGNORE
false makes Glob respect .gitignore
CLAUDE_CODE_GLOB_TIMEOUT_SECONDS
Glob discovery timeout (20 seconds; 60 on WSL)
USE_BUILTIN_RIPGREP
0 uses your system rg
CLAUDE_CODE_USE_NATIVE_FILE_SEARCH
Discover commands, subagents and output styles with Node APIs when the bundled ripgrep is blocked
CLAUDE_CODE_DISABLE_ATTACHMENTS
Send @ mentions as plain text instead of expanding them
CLAUDE_CODE_PERFORCE_MODE
1 makes Edit, Write and NotebookEdit fail with a p4 edit <file> hint on read-only synced files
WebSearch cap (default 200; positive integers; cannot be disabled) (v2.1.212)
CLAUDE_CODE_WEB_SEARCH_REFILLS_PER_HOUR
Refill rate for that cap (100 interactive, 0 non-interactive; plain digits) (v2.1.290)
CLAUDE_CODE_ENABLE_TASKS
0 gives the legacy TodoWrite instead of the Task tools
CLAUDE_CODE_ENABLE_TODO_TOOLS
1 provides task tools on every model (v2.1.233)
CLAUDE_CODE_TASK_LIST_ID
Share a named task list across sessions
TASK_MAX_OUTPUT_LENGTH
Removed in v2.1.277; no effect
MCP
Variable
Purpose
MCP_TIMEOUT
Server start-up timeout (default 30000)
MCP_TOOL_TIMEOUT
Tool execution timeout (default about 28 hours). HTTP, SSE and connector servers also have a 60-second per-request limit unless this or the per-server timeout exceeds 60000. Values under 1000 are floored to one second
CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT
Abort a tool call with no response or progress for this long (defaults: 5 minutes for network servers, 30 for stdio); 0 disables. Min one second, capped at MCP_TOOL_TIMEOUT; a per-server timeout of 1000 or more sets a floor (v2.1.187)
MAX_MCP_OUTPUT_TOKENS
Max tokens in an MCP result (default 25000, warning above 10,000). Tools with anthropic/maxResultSizeChars use that for text; text results over 50,000 characters are saved to a file anyway
CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH
Max characters of each tool description and server instructions sent to the model (default 2048; plain digits) (v2.1.280)
MCP_CONNECTION_NONBLOCKING
0 makes start-up wait for servers before the first query (non-blocking is the default; alwaysLoad servers and -p without stream-json input still wait)
MCP_CONNECT_TIMEOUT_MS
How long blocking start-up waits for the connection batch (default 5000)
CLAUDE_CODE_MCP_STARTUP_WAIT_MS
How long a non-interactive first turn waits for pending servers; 0 skips. A --permission-prompt-tool server keeps its own wait (v2.1.274)
MCP_SERVER_CONNECTION_BATCH_SIZE
Local stdio servers connected in parallel (default 3)
MCP_REMOTE_SERVER_CONNECTION_BATCH_SIZE
Remote servers connected in parallel (default 20)
CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS
Move long MCP calls to the background after this long (default 120000; 0 disables) (v2.1.212)
ENABLE_TOOL_SEARCH
Tool search: unset defers MCP tools (except on pre-4.5 Agent Platform models, Azure-hosted Foundry and non-first-party base URLs); true always defers; auto or auto:N loads up front when definitions fit within 10% (or N%) of context; false loads everything. Ignored when experimental betas are disabled
ENABLE_CLAUDEAI_MCP_SERVERS
false stops fetching claude.ai connectors; per project or org, use disableClaudeAiConnectors
MCP_CLIENT_SECRET
OAuth client secret for pre-configured credentials
MCP_OAUTH_CALLBACK_PORT
Fixed OAuth callback port
CLAUDE_CODE_MCP_ALLOWLIST_ENV
Start stdio servers with only a safe baseline environment plus their own env
MCP_DISCOVERY_CACHE
1/0 to turn the discovery cache on or off (off by default unless rolled out to you)
MCP_DISCOVERY_CACHE_TTL_S
Use a cache entry without refreshing for this long (default 900)
MCP_DISCOVERY_CACHE_MAX_STALE_S
Discard entries older than this (default 14400; max 7 days)
MCP_DISCOVERY_CACHE_STRIKES
Failed background refreshes tolerated before discarding (default 1) (v2.1.238)
MCP_PROTOCOL_NEGOTIATION
v2 runtime only: auto probes HTTP, connector and stdio servers for protocol 2026-07-28; legacy probes none (v2.1.221)
MCP_SDK_GENERATION
Pin the MCP client runtime, v1 or v2 (the default). The v2 runtime checks the OAuth issuer and fails on mismatch (v2.1.218)
CLAUDE_AGENT_SDK_MCP_NO_PREFIX
SDK only: drop the mcp__<server>__ prefix from SDK-created server tools
Do not stop background shells under memory pressure (macOS and Linux)
CLAUDE_CODE_BG_TASKS_REPORT_RUNNING
0 reports idle at every turn end in non-interactive sessions even while background agents or workflows run (default keeps reporting running)
CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS
In -p, the idle wait ceiling for background work after the final turn (default 600000; 0 waits forever)
CLAUDE_CODE_DISABLE_AGENT_VIEW
Turn off background agents and agent view (claude agents, --bg, /background, supervisor); same as disableAgentView
CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFF
Stop a background session's running shells, workflows and subagents when the supervisor restarts or updates it, instead of handing them over (v2.1.196)
CLAUDE_DISABLE_ADOPT
Stop in-flight work (after confirming) instead of carrying it over when you background a session (v2.1.195)
Skip auto-registering the official marketplace, permanently once skipped
FORCE_AUTOUPDATE_PLUGINS
Keep plugin auto-update on when DISABLE_AUTOUPDATER is set
CLAUDE_CODE_DISABLE_BUNDLED_SKILLS
Remove bundled skills and workflows; built-in commands stay typable but hidden from the model. Same as disableBundledSkills
CLAUDE_CODE_DISABLE_POLICY_SKILLS
Skip the system-wide managed skills directory
CLAUDE_CODE_SYNC_SKILLS
In -p, download your claude.ai skills and wait for the list before the first query
CLAUDE_CODE_SYNC_SKILLS_WAIT_TIMEOUT_MS
That wait (default 5000)
CLAUDE_CODE_SYNC_SKILLS_INSTALL_TIMEOUT_MS
Mid-session skills resync timeout for SDK reloads (default 30000)
Sessions, history and configuration
Variable
Purpose
CLAUDE_CONFIG_DIR
Configuration directory (default ~/.claude). Handy for separate accounts: alias claude-clients='CLAUDE_CONFIG_DIR=$HOME/.claude-clients claude'. Not settable from project or local settings
CLAUDE_CODE_PROJECT_DIR_NAME
With CLAUDE_CONFIG_DIR, the projects/ folder name for this session's transcripts and memory; read only from the launch environment (v2.1.234). See Sessions
CLAUDE_CODE_TMPDIR
Temp directory base (Claude Code appends /claude-{uid}/ or /claude/). Not settable from project or local settings
CLAUDE_CODE_SKIP_PROMPT_HISTORY
Do not write prompt history or transcripts; sessions do not appear in resume or history
CLAUDE_CODE_FORCE_SESSION_PERSISTENCE
Persist and register sessions even when an inherited CLAUDE_CODE_CHILD_SESSION makes a top-level session look nested
CLAUDE_CODE_TRANSCRIPT_LOCAL_GC
In long -p or SDK sessions, trim pre-compaction history once the transcript passes 5 MB; launch environment only (v2.1.287)
CLAUDE_CODE_RESUME_INTERRUPTED_TURN
Resume automatically if the last session ended mid-turn (SDK use)
CLAUDE_CODE_RESUME_INTERRUPTED_TURN_MAX_AGE_MS
Skip that resume when the last message is older than this; unset means unbounded except a six-hour limit for API-error endings (v2.1.211)
CLAUDE_CODE_RESUME_PROMPT
Continuation message for those resumes and deferred tool calls; default Continue from where you left off.
CLAUDE_CODE_EXIT_AFTER_STOP_DELAY
Exit automatically this many ms after the query loop goes idle (SDK scripts)
CLAUDE_CODE_MAX_TURNS
Default turn cap when none is passed; --max-turns wins; invalid values error at start-up
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD
Load CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md and CLAUDE.local.md from --add-dir directories
CLAUDE_CODE_DISABLE_CLAUDE_MDS
Load no CLAUDE.md files at all, user, project or memory
CLAUDE_CODE_DISABLE_AUTO_MEMORY
1 disables auto memory; 0 forces it on even under --bare or autoMemoryEnabled: false
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS
Remove built-in commit/PR instructions and the git status snapshot; beats includeGitInstructions
CLAUDE_CODE_NEW_INIT
Make /init an interactive flow covering CLAUDE.md, skills and hooks
CLAUDE_CODE_SIMPLE
Same as --bare: minimal prompt, only Bash and file tools, no auto-discovery, no OAuth or keychain (use ANTHROPIC_API_KEY or an apiKeyHelper in --settings)
CLAUDE_CODE_SAFE_MODE
Same as --safe-mode; inherited by direct child processes
CLAUDE_CODE_RESTRICTED
Same as --restricted; ignored in settings env (v2.1.248)
CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS
Add session_state_changed messages to the SDK or stream-json output
CLAUDE_CODE_STARTUP_FAILURE_RESULTS
With stream-json output, write a result message explaining start-up refusals (v2.1.274)
CLAUDE_CODE_FORWARD_SUBAGENT_TEXT
Same as --forward-subagent-text, but silently ignored outside stream-json -p (v2.1.211)
CLAUDE_CODE_USER_DIALOG_TIMEOUT_MS
Deadline for dialogs forwarded to remote or SDK clients and held cross-session message approvals; 0 or negative disables. Beats dialogExpiry
CLAUDE_CODE_STOP_HOOK_BLOCK_CAP
Consecutive Stop/SubagentStop blocks allowed before the turn ends anyway (default 8; 0 disables)
CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS
Time budget for SessionEnd hooks (default 1.5 s, raised to the largest per-hook timeout up to 60 s; plugin hook timeouts do not raise it)
CLAUDE_CODE_PROCESS_WRAPPER
Launcher prefix for processes started from Claude Code's binary, such as the agent view service. Set in user or managed env; ignored on Windows. See Corporate launcher
CLAUDE_CODE_DISABLE_ADMIN_ENV_UNION
Use only the highest-priority managed source's whole env block instead of merging per key; set in the launch environment (v2.1.223)
CCR_FORCE_BUNDLE
Make claude --cloud upload a bundle of your local repository instead of cloning its remote
Not a removal: treats a failed fast mode availability check as available, for networks that block the check's request to api.anthropic.com (an explicit organisation "disabled" is still honoured)
CLAUDE_CODE_SKIP_FAST_MODE_ORG_CHECK
Not a removal: skips the client-side fast mode check for proxies that intercept it; the API still rejects fast mode if your organisation disabled it
CLAUDE_CODE_DISABLE_ADVISOR_TOOL
The advisor; --advisor is accepted but ignored
CLAUDE_CODE_DISABLE_ARTIFACT
The Artifact tool, irreversibly for that session (settings: enableArtifact: false)
CLAUDE_CODE_DISABLE_CFC_PROMPT
The Chrome section of the system prompt and /claude-in-chrome, keeping browser tools (v2.1.257)
CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY
"How is Claude doing?" surveys (also off with telemetry opt-outs unless re-enabled for OTel)
CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTEL
Route those surveys to your own OTel collector when Anthropic-bound traffic is blocked
CLAUDE_CODE_SEND_FEEDBACK
0 disables Claude-drafted feedback for the session
DISABLE_FEEDBACK_COMMAND
/feedback, /bug, /share and drafted feedback (old name DISABLE_BUG_COMMAND accepted)
DISABLE_DOCTOR_COMMAND
The /doctor skill and /checkup (not claude doctor)
DISABLE_EXTRA_USAGE_COMMAND
/usage-credits
DISABLE_INSTALL_GITHUB_APP_COMMAND
/install-github-app
DISABLE_LOGIN_COMMAND, DISABLE_LOGOUT_COMMAND
/login, /logout
DISABLE_UPGRADE_COMMAND
/upgrade
DISABLE_COST_WARNINGS
Cost warning messages
DISABLE_INSTALLATION_CHECKS
Installation warnings (only if you manage the install location yourself)
CLAUDE_CODE_ENABLE_AUTO_MODE
Nothing; accepted for compatibility (auto mode is available everywhere)
CLAUDE_CODE_AUTO_MODE_SERVER
0 uses local classifier requests instead of server-side review (v2.1.271)
Updates, telemetry and privacy
Variable
Purpose
DISABLE_AUTOUPDATER
Stop background updates (and plugin auto-update unless forced); claude update still works
DISABLE_UPDATES
Block all updates, manual included
CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE
Let Claude Code run Homebrew or WinGet upgrades in the background
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC
Presence-only. Disables auto-updates, telemetry, error reporting, /feedback, drafted feedback, release notes, PR/MR badge checks, availability checks, and background command-source plugin runs; also disables feature-flag fetching. Does not cover official marketplace auto-install or gateway model discovery
DISABLE_TELEMETRY
Presence-only telemetry opt-out (events never contain code, paths or commands); also disables feature flags
DO_NOT_TRACK
Same effect, but a normal boolean, so 0 leaves telemetry on
DISABLE_ERROR_REPORTING
Presence-only error reporting opt-out
DISABLE_GROWTHBOOK
1 or true disables feature-flag fetching and uses code defaults; 0/false leaves fetching on
DEBUG
1, true, yes or on enables debug mode (patterns like express:* do not)
Set the variables that switch on export, choose a destination or capture content in your shell, user settings or managed settings; project and local settings ignore them (except their off values). OTEL_RESOURCE_ATTRIBUTES and interval, timeout and compression variables do apply from project settings. Full details are on Monitoring usage.
Variable
Purpose
CLAUDE_CODE_ENABLE_TELEMETRY
1 enables OTel collection; required before exporters
Standard OTEL_* exporter variables
OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_HEADERS, OTEL_METRIC_EXPORT_INTERVAL, OTEL_RESOURCE_ATTRIBUTES and signal-specific variants
OTEL_LOG_USER_PROMPTS
Include prompt text (redacted by default)
OTEL_LOG_ASSISTANT_RESPONSES
Include response text; defaults to the prompts setting, 0 keeps it redacted (v2.1.193)
OTEL_LOG_TOOL_DETAILS
Include tool arguments, MCP server and workflow names, raw tool errors, refusal categories and real agent/skill/plugin/server names on cost metrics
OTEL_LOG_TOOL_CONTENT
Include tool content on the tool.output span event (needs tracing)
OTEL_LOG_RAW_API_BODIES
1 for inline request/response bodies, or file:<dir> to write them untruncated and log a body_ref
OTEL_LOG_MANAGED_SETTINGS
Add redacted managed settings and a pre-redaction digest to managed_settings_resolved events (v2.1.274)
OTEL_METRICS_INCLUDE_SESSION_ID
false drops session id (included by default)
OTEL_METRICS_INCLUDE_ACCOUNT_UUID
false drops account UUID (included)
OTEL_METRICS_INCLUDE_VERSION
true adds the version (excluded)
OTEL_METRICS_INCLUDE_ENTRYPOINT
true adds the entrypoint (excluded)
OTEL_METRICS_INCLUDE_REPOSITORY
true adds vcs.* repository attributes (v2.1.269)
OTEL_METRICS_INCLUDE_RESOURCE_ATTRIBUTES
false stops copying resource attributes to datapoint labels
OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT
SDK attribute limit; content attributes use the smaller of this and the next variable (log and span variants read too)
CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH
Max length of content-bearing attributes (default 61440 UTF-16 units)
CLAUDE_CODE_OTEL_DIAG_STDERR
Print exporter errors to stderr (otherwise only with --debug)
CLAUDE_CODE_OTEL_FLUSH_TIMEOUT_MS
Span flush timeout (default 5000)
CLAUDE_CODE_OTEL_SHUTDOWN_TIMEOUT_MS
Exporter shutdown timeout (default 2000)
CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS
Dynamic header refresh interval (default 1740000)
ENABLE_BETA_TRACING_DETAILED
With BETA_TRACING_ENDPOINT, detailed beta tracing; interactive CLI needs an allowlisted organisation
BETA_TRACING_ENDPOINT
OTLP/HTTP endpoint for detailed tracing
Security hardening
Variable
Purpose
CLAUDE_CODE_SUBPROCESS_ENV_SCRUB
Strip credentials from subprocess environments; see below
CLAUDE_CODE_SCRIPT_CAPS
With the scrub on, JSON limits per script substring, e.g. {"publish.sh": 1}. Substring matching catches ./publish.sh $(...), but not xargs or find -exec fan-out
CLAUDE_CODE_DISABLE_DANGEROUS_RM_TIMEOUT
Remove the time limit on critical-path removal prompts (auto mode sends them to the classifier; bypass mode waits). Launch environment only (v2.1.281)
CLAUDE_CODE_DISABLE_SUBSTITUTION_RM_PROMPT
Stop checking recursive rm whose whole target is a command substitution, like rm -rf "$(pwd)". Launch environment only (v2.1.281)
CLAUDE_CODE_DISABLE_INLINE_SHELL_RM_PROMPT
Stop reading bash -c '...' scripts for critical-path removals. Launch environment only (v2.1.288)
CLAUDE_CODE_DISABLE_POWERSHELL_CMD_RM_DENY
Disable the PowerShell deny for rd, rmdir, del and erase on system paths; ignored in settings env (v2.1.283)
With CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1, Bash commands, hooks and stdio MCP servers start without your credentials, which limits what a prompt injection can steal. Claude Code itself keeps them for its own API calls. Detection is by variable name or value shape, so treat it as one layer alongside tight permissions.
Example
Result
ANTHROPIC_API_KEY, AWS_SECRET_ACCESS_KEY
Removed
NPM_TOKEN, DB_PASSWORD
Removed (name looks like a credential)
DATABASE_URL with an embedded password
Removed (value looks like a credential)
PIP_INDEX_URL or NPM_CONFIG_REGISTRY with embedded credentials
Because GitHub tokens survive, give CI jobs the narrowest permissions, and deny them to sandboxed commands via sandbox.credentials if needed (see Sandboxing). On Linux the scrub also isolates Bash in its own PID namespace so it cannot read other processes' environments via /proc, which means ps, pgrep and kill cannot see host processes. claude-code-action turns the scrub on when allowed_non_write_users is set. (Before v2.1.251 it only removed the first two rows.)
Variables Claude Code sets for you
Read these in scripts and hooks; do not set them.
Variable
Meaning
CLAUDECODE
1 in subprocesses Claude Code spawns (tools, tmux, hooks, status line, stdio MCP servers), and in IDE-integrated terminals
CLAUDE_CODE_CHILD_SESSION
1 only in processes Claude Code itself launched via Bash, PowerShell, Monitor, hooks or status line (not MCP servers, not IDE terminals). Nested interactive sessions are excluded from resume, history and claude agents
CLAUDE_CODE_SESSION_ID
Current session id in tool, hook and stdio MCP subprocesses; updated on /clear for tools and hooks
CLAUDE_CODE_BRIDGE_SESSION_ID
The session_... id while Remote Control is connected (v2.1.199)
CLAUDE_CODE_REMOTE
true in cloud sessions
CLAUDE_CODE_REMOTE_SESSION_ID
Session id in cloud sessions, for linking back to the transcript
CLAUDE_EFFORT
Effort level at subprocess start, when the model supports effort
CLAUDE_PID
Claude Code's process id, in tool and hook subprocesses (v2.1.214)
CLAUDE_JOB_DIR
A background session's ~/.claude/jobs/<id> folder; scratch files go in $CLAUDE_JOB_DIR/tmp
Per-session token to authenticate to that socket; mandatory on native Windows (v2.1.228)
Agent Platform region overrides
Each overrides the Google Cloud region for one model: VERTEX_REGION_CLAUDE_3_5_HAIKU, VERTEX_REGION_CLAUDE_3_5_SONNET, VERTEX_REGION_CLAUDE_3_7_SONNET, VERTEX_REGION_CLAUDE_4_0_OPUS, VERTEX_REGION_CLAUDE_4_0_SONNET, VERTEX_REGION_CLAUDE_4_1_OPUS, VERTEX_REGION_CLAUDE_4_5_OPUS, VERTEX_REGION_CLAUDE_4_5_SONNET, VERTEX_REGION_CLAUDE_4_6_OPUS, VERTEX_REGION_CLAUDE_4_6_SONNET, VERTEX_REGION_CLAUDE_4_7_OPUS, VERTEX_REGION_CLAUDE_4_8_OPUS, VERTEX_REGION_CLAUDE_5_OPUS (v2.1.219), VERTEX_REGION_CLAUDE_5_SONNET (v2.1.197), VERTEX_REGION_CLAUDE_5_5_OPUS (v2.1.280), VERTEX_REGION_CLAUDE_5_5_SONNET (v2.1.284), VERTEX_REGION_CLAUDE_HAIKU_4_5, VERTEX_REGION_CLAUDE_HAIKU_5_5 (v2.1.293), VERTEX_REGION_CLAUDE_FABLE_5 (v2.1.170) and VERTEX_REGION_CLAUDE_FABLE_5_1 (v2.1.257).
Removed variables
CLAUDE_CODE_CONNECT_TIMEOUT_MS (v2.1.186), CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE (v2.1.160), CLAUDE_CODE_ENABLE_OPUS_4_7_FAST_MODE (v2.1.142), CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION (v2.1.224), CLAUDE_SUBAGENT_BG_SHELL_MAX_MS (v2.1.260), TASK_MAX_OUTPUT_LENGTH (v2.1.277) and CLAUDE_CODE_AUTO_BACKGROUND_WORKER_CHECKIN_SECONDS (v2.1.283) no longer do anything.
Features that need feature-flag fetching
Some features are switched on by flags Claude Code fetches from Anthropic. Fetching is skipped when DISABLE_GROWTHBOOK, DISABLE_TELEMETRY, DO_NOT_TRACK or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC turn it off; on third-party providers (Bedrock, Claude Platform on AWS, Agent Platform, Foundry) unless the host sets CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST; and in Claude apps gateway sessions.
Without it you lose:
/auto-mode-setup.
Remote Control when CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC or DISABLE_GROWTHBOOK is set (the telemetry variables have their own rules), and therefore messaging sessions on other machines (same-machine messaging still works).
claude import and /import.
/skill-doctor and the /plugin Stats tab.
Syncing claude.ai skills and plugins into terminal sessions.
The advisor.
Reading and replying to artifact comments, and reading other organisations' public artifacts.
Probing connectors for MCP protocol 2026-07-28, unless MCP_PROTOCOL_NEGOTIATION=auto.
The PowerShell tool by default on Windows with Git Bash (set CLAUDE_CODE_USE_POWERSHELL_TOOL=1); Windows without Git Bash keeps it.
Claude-drafted feedback.
Marking large pastes as pasted rather than typed.
Excluding MCP tools whose schemas the API would reject (requests including them fail with a 400 naming the tool's position).
The first session after install or upgrade
A flag-gated feature can be missing in your first session after installing or upgrading, and that session may start in a different permission mode. Flags fetched during it are saved, so the next session is normal. Non-interactive first sessions (-p, the SDK, VS Code) may or may not wait for flags before choosing the mode.
Every session behaves like a first session when the environment is wiped each run (CI containers), or when you authenticate with ANTHROPIC_AUTH_TOKEN and no API key against a non-Anthropic ANTHROPIC_BASE_URL, since there is no credential to fetch flags with. Set the starting permission mode explicitly in those setups.