Skip to content

Environment variables

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:

{
  "env": {
    "BASH_DEFAULT_TIMEOUT_MS": "300000",
    "CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "1"
  }
}

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:

FileApplies to
~/.claude/settings.jsonYou, everywhere
.claude/settings.jsonEveryone on the project (committed)
.claude/settings.local.jsonYou, in this project (git-ignored when Claude Code writes it; ignore it yourself if you create it by hand)
Managed settingsEveryone 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

VariablePurpose
ANTHROPIC_API_KEYAPI 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_TOKENValue for the Authorization header, prefixed with Bearer
ANTHROPIC_PROFILENamed Anthropic profile to authenticate with, e.g. one from ant auth login or a Console sign-in without a key. See Authentication
ANTHROPIC_FEDERATION_RULE_IDWorkload Identity Federation rule id. With ANTHROPIC_ORGANIZATION_ID, federation credentials rank above /login
ANTHROPIC_ORGANIZATION_IDOrganisation id for Workload Identity Federation
ANTHROPIC_WORKSPACE_IDWorkspace to target when a federation rule spans several workspaces
CLAUDE_CODE_OAUTH_TOKENclaude.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_TOKENRefresh token that claude auth login exchanges without a browser. Needs CLAUDE_CODE_OAUTH_SCOPES
CLAUDE_CODE_OAUTH_SCOPESSpace-separated scopes the refresh token was issued with, e.g. "user:profile user:inference user:sessions:claude_code"
CLAUDE_CODE_API_KEY_HELPER_TTL_MSHow often to refresh credentials from apiKeyHelper
CLAUDE_CODE_DISABLE_AUTH_REFRESH_LOCK1 makes each process run gcpAuthRefresh/awsAuthRefresh itself rather than waiting for another (v2.1.286)

Choosing a provider

VariablePurpose
CLAUDE_CODE_USE_BEDROCKUse Amazon Bedrock
CLAUDE_CODE_USE_MANTLEUse Bedrock's Mantle endpoint
CLAUDE_CODE_USE_VERTEXUse Google Cloud's Agent Platform
CLAUDE_CODE_USE_FOUNDRYUse Microsoft Foundry
CLAUDE_CODE_USE_ANTHROPIC_AWSUse Claude Platform on AWS
ANTHROPIC_BASE_URLRoute 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_HOSTSet 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

VariablePurpose
AWS_BEARER_TOKEN_BEDROCKBedrock API key
ANTHROPIC_BEDROCK_BASE_URLCustom Bedrock endpoint or gateway
ANTHROPIC_BEDROCK_MANTLE_BASE_URLCustom Mantle endpoint
ANTHROPIC_BEDROCK_REGION_PREFIXCross-region inference prefix to try first: us, eu, apac, jp, au or global. Ignored in GovCloud (v2.1.224)
ANTHROPIC_BEDROCK_SERVICE_TIERdefault, flex or priority, sent as X-Amzn-Bedrock-Service-Tier
ANTHROPIC_SMALL_FAST_MODEL_AWS_REGIONRegion 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_AUTHSkip AWS auth, e.g. behind a gateway
CLAUDE_CODE_SKIP_MANTLE_AUTHSkip AWS auth for Mantle
CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MSHow 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_CACHE1 resolves the AWS chain on every request instead of caching (v2.1.207)
CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_GUARDSkip the check that streams arrive as application/vnd.amazon.eventstream. Better to fix the gateway (v2.1.208)
CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_DEFAULTStop 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_BEDROCK1 enables the byte-level idle watchdog and first-byte deadline on Bedrock streams

Google Cloud's Agent Platform

VariablePurpose
ANTHROPIC_VERTEX_PROJECT_IDGCP project requests are addressed to
ANTHROPIC_VERTEX_BASE_URLCustom endpoint or gateway
CLAUDE_CODE_SKIP_VERTEX_AUTHSkip Google auth, e.g. behind a gateway
VERTEX_REGION_CLAUDE_*Per-model region overrides; see the list below

Microsoft Foundry

VariablePurpose
ANTHROPIC_FOUNDRY_RESOURCEResource name such as cam-ai-uk; URLs and host names are refused. Required unless ANTHROPIC_FOUNDRY_BASE_URL is set
ANTHROPIC_FOUNDRY_BASE_URLFull resource URL, e.g. https://cam-ai-uk.services.ai.azure.com/anthropic
ANTHROPIC_FOUNDRY_API_KEYFoundry API key
ANTHROPIC_FOUNDRY_AUTH_TOKENBearer token such as an Entra access token; beats the API key and the Azure credential chain (v2.1.203)
CLAUDE_CODE_SKIP_FOUNDRY_AUTHSend no Azure credential and keep your own Authorization header (e.g. via ANTHROPIC_CUSTOM_HEADERS). Ignored if a Foundry key or token is set

Claude Platform on AWS

VariablePurpose
ANTHROPIC_AWS_WORKSPACE_IDRequired; sent as anthropic-workspace-id
ANTHROPIC_AWS_API_KEYWorkspace API key from the AWS Console, sent as x-api-key, beating SigV4
ANTHROPIC_AWS_BASE_URLEndpoint override; default https://aws-external-anthropic.{region}.api.aws
CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTHSkip client-side auth for gateways that sign requests themselves

Request shaping for gateways

VariablePurpose
ANTHROPIC_CUSTOM_HEADERSExtra 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_BETASExtra anthropic-beta values, comma-separated; unlike --betas, works with any auth method
CLAUDE_CODE_EXTRA_BODYJSON merged into the top level of every request body. Shell exports also reach background sessions (v2.1.206)
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETASStrip 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_OUTPUTSStop sending output_config.format and its beta, leaving other betas on (v2.1.288)
CLAUDE_CODE_DISABLE_THINKINGOmit the thinking parameter for proxies that reject it. Models that think by default may still think
DISABLE_INTERLEAVED_THINKINGDo not send the interleaved-thinking beta header
CLAUDE_CODE_ALWAYS_ENABLE_EFFORTSend effort even for unrecognised model ids (models that reject it at the API are still excluded)
CLAUDE_CODE_ATTRIBUTION_HEADER0 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_HEADERS1 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_DISCOVERY1 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_MSTimeout for that discovery call (default 3000; plain digits) (v2.1.269)
CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMINGStream 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_TRACEPARENT1 propagates W3C trace context (the traceparent header and TRACEPARENT for subprocesses) through a custom proxy; by default only direct connections propagate

Models

VariablePurpose
ANTHROPIC_MODELModel to use. Beats the model setting; loses to --model and /model. See Model configuration
ANTHROPIC_DEFAULT_MODELModel new sessions start on (v2.1.236)
ANTHROPIC_DEFAULT_OPUS_MODELWhat opus resolves to; also opusplan in plan mode
ANTHROPIC_DEFAULT_SONNET_MODELWhat sonnet resolves to; also opusplan outside plan mode
ANTHROPIC_DEFAULT_HAIKU_MODELWhat haiku resolves to; also used for background work
ANTHROPIC_DEFAULT_FABLE_MODELWhat fable resolves to, and recognised as a Fable model for automatic fallback on third-party providers
ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU,FABLE}_MODEL_NAMEDisplay name for that pinned model in /model; defaults to the recognised model name or the raw id
ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU,FABLE}_MODEL_DESCRIPTIONDescription in /model; defaults to text beginning Custom Opus model (and so on)
ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU,FABLE}_MODEL_SUPPORTED_CAPABILITIESComma-separated capabilities such as effort,thinking
ANTHROPIC_CUSTOM_MODEL_OPTIONAdd an extra model id to the /model picker
ANTHROPIC_CUSTOM_MODEL_OPTION_NAMEIts display name
ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTIONIts description; default Custom model (<id>)
ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIESIts capabilities
ANTHROPIC_SMALL_FAST_MODELDeprecated name for the Haiku-class background model
CLAUDE_CODE_SUBAGENT_MODELDefault 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_FORCE1 forces one model on all of them (v2.1.257). See Subagents
CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAPStop remapping Opus 4.0 and 4.1 to the current Opus on the Anthropic API
CLAUDE_CODE_DISABLE_MODEL_ACCESS_FALLBACKOn 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_MEMORYForget which models the start-up checks found unavailable (normally remembered for up to a day) (v2.1.285)
CLAUDE_CODE_DISABLE_REFUSAL_FALLBACKTurn off the automatic model switch when a safety classifier flags a request (the switchModelsOnFlag behaviour)
FALLBACK_FOR_ALL_PRIMARY_MODELSPresence-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

VariablePurpose
CLAUDE_CODE_EFFORT_LEVELlow, medium, high, xhigh, max or auto. Beats --effort, /effort, modelSettings and effortLevel; maxEffortLevel still caps it
MAX_THINKING_TOKENSFixed 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_THINKINGUse the fixed budget instead of adaptive reasoning on Opus 4.6 and Sonnet 4.6; no effect on newer models
CLAUDE_CODE_MAX_OUTPUT_TOKENSMax 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_TOKENSRaise the token limit for file reads
CLAUDE_CODE_DISABLE_1M_CONTEXTHide 1M variants and hold native-1M models (Sonnet 5.5, Fable) to 200K
CLAUDE_CODE_MAX_CONTEXT_TOKENSCorrect the assumed context window for a model id, e.g. a gateway alias. See Model configuration
CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENTSkip proactive compaction for unrecognised model ids (v2.1.223)
CLAUDE_CODE_AUTO_COMPACT_WINDOWAuto-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_OVERRIDETrigger compaction earlier, at this percentage (1 to 100) of the window; cannot raise the threshold. Applies to main conversations and subagents
DISABLE_AUTO_COMPACTTurn off auto-compaction; /compact still works. Beats autoCompactEnabled
DISABLE_COMPACTTurn off all compaction, manual included
CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT1 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_RETRIESAttempts allowed for --json-schema output (and workflow subagent structured output) before failing; default 5
SLASH_COMMAND_TOOL_CHAR_BUDGETCharacter budget for skill metadata shown to the Skill tool; default 1% of the context window, fallback 8,000

Prompt caching

VariablePurpose
DISABLE_PROMPT_CACHINGOff for all models (beats the per-model ones)
DISABLE_PROMPT_CACHING_OPUS / _SONNET / _HAIKU / _FABLEOff for that family's default model
ENABLE_PROMPT_CACHING_1HRequest 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_BEDROCKDeprecated; use the above
CLAUDE_CODE_PROMPT_CACHE_TTL5m or 1h for the main conversation; beats promptCacheTtl and ENABLE_PROMPT_CACHING_1H (v2.1.242)
CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL5m or 1h for subagents, workflows and background work; beats subagentPromptCacheTtl (v2.1.242)
FORCE_PROMPT_CACHING_5MForce 5 minutes, overriding all of the above
CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MSHow 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)

Prompt caching explains TTLs and costs.

Network, timeouts and retries

VariablePurpose
HTTP_PROXY, HTTPS_PROXYProxy servers
NO_PROXYHosts and IPs that bypass the proxy
CLAUDE_CODE_PROXY_RESOLVES_HOSTS1 lets the proxy do DNS resolution
CLAUDE_CODE_CERT_STORECA sources: bundled (Mozilla set shipped with Claude Code), system (OS store, on runtimes with tls.getCACertificates). Default bundled,system. See Network configuration
CLAUDE_CODE_CLIENT_CERTmTLS client certificate path
CLAUDE_CODE_CLIENT_KEYmTLS private key path
CLAUDE_CODE_CLIENT_KEY_PASSPHRASEPassphrase for an encrypted key
CLAUDE_CODE_DISABLE_MTLS_RELOAD_ON_STALE_CONNECTIONDo not re-read rotated mTLS files after connection-level errors (v2.1.232)
CLAUDE_CODE_GZIP_REQUEST_BODIES0 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_MSPer-request timeout; default 600000 (10 minutes), max 2147483647 (higher overflows and fails instantly)
API_FORCE_IDLE_TIMEOUTThe 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_RETRIESRetries for failed requests (default 10, capped at 15 unless the retry watchdog is on)
CLAUDE_CODE_RETRY_WATCHDOGFor 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_RETRIESCap re-sends of timed-out non-streaming requests; 0 fails on the first (v2.1.285)
CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACKDo 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_WATCHDOG0/1 to force the event-level idle watchdog off or on (on by default for all providers)
CLAUDE_ENABLE_BYTE_WATCHDOG0/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_MSIdle 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_MSByte-watchdog-only timeout, clamped to 10 seconds to 30 minutes (v2.1.210)
CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MSDeadline for the first byte of a streaming response where that deadline runs (v2.1.242). See Errors
CLAUDE_ASYNC_AGENT_STALL_TIMEOUT_MSStall timeout for subagents (default 600000), reset by each progress event; rises with a raised stream idle timeout
CLAUDE_CODE_CONNECT_TIMEOUT_MSRemoved in v2.1.186; no effect

Shell, tools and files

VariablePurpose
BASH_DEFAULT_TIMEOUT_MSDefault foreground Bash/PowerShell timeout (120000). Above 30 minutes it also becomes the background time limit default in unattended sessions
BASH_MAX_TIMEOUT_MSHighest 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_LENGTHCharacters of output read back (default 30000, max 150000); ignored if bashOutputMaxChars is set. See Tools reference
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIRReturn to the project directory after every Bash or PowerShell command
CLAUDE_ENV_FILEScript sourced before each Bash command, for persistent exports such as virtualenv activation; also filled by SessionStart, Setup, CwdChanged and FileChanged hooks
CLAUDE_CODE_SHELLPath 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_PREFIXWrapper 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_PATHWindows: path to bash.exe if not on PATH. Invalid paths or names are ignored with a debug warning
CLAUDE_CODE_USE_POWERSHELL_TOOLControl the PowerShell tool; see Tools reference for per-platform defaults
CLAUDE_CODE_POWERSHELL_RESPECT_EXECUTION_POLICYDo not pass -ExecutionPolicy Bypass; honour the machine policy
CLAUDE_CODE_DISABLE_WINDOWS_SHELL_LAUNCHERStart PowerShell commands directly rather than through cmd.exe; backgrounded PowerShell commands then stop when the process exits (v2.1.269)
CLAUDE_CODE_BASH_EDIT_DIFF0 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_LIMITLinux/WSL memory cap for Bash, PowerShell and Monitor commands, e.g. 4G; 0 or off disables (v2.1.233)
CLAUDE_CODE_TOOL_MEMORY_CGROUP_EXCLUDEProcess kinds exempt from that cap: mcp, lsp, hooks, plugin, helper, agent; none or all-new (v2.1.246)
CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCYRead-only tools and subagents run in parallel (default 10)
CLAUDE_CODE_GLOB_HIDDENfalse excludes dotfiles from Glob results
CLAUDE_CODE_GLOB_NO_IGNOREfalse makes Glob respect .gitignore
CLAUDE_CODE_GLOB_TIMEOUT_SECONDSGlob discovery timeout (20 seconds; 60 on WSL)
USE_BUILTIN_RIPGREP0 uses your system rg
CLAUDE_CODE_USE_NATIVE_FILE_SEARCHDiscover commands, subagents and output styles with Node APIs when the bundled ripgrep is blocked
CLAUDE_CODE_DISABLE_ATTACHMENTSSend @ mentions as plain text instead of expanding them
CLAUDE_CODE_PERFORCE_MODE1 makes Edit, Write and NotebookEdit fail with a p4 edit <file> hint on read-only synced files
CLAUDE_CODE_DISABLE_FILE_CHECKPOINTINGDisable checkpointing; beats fileCheckpointingEnabled
CLAUDE_CODE_DISABLE_WEB_FETCHTurn off WebFetch; WebSearch stays (v2.1.285)
CLAUDE_CODE_WEBFETCH_CACHE_TTL_MSWebFetch cache lifetime (default 900000; plain digits; read once per launch) (v2.1.233)
CLAUDE_CODE_WEBFETCH_DEADLINE_MSWebFetch download deadline (default 300000; 0 removes) (v2.1.268)
CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSIONWebSearch cap (default 200; positive integers; cannot be disabled) (v2.1.212)
CLAUDE_CODE_WEB_SEARCH_REFILLS_PER_HOURRefill rate for that cap (100 interactive, 0 non-interactive; plain digits) (v2.1.290)
CLAUDE_CODE_ENABLE_TASKS0 gives the legacy TodoWrite instead of the Task tools
CLAUDE_CODE_ENABLE_TODO_TOOLS1 provides task tools on every model (v2.1.233)
CLAUDE_CODE_TASK_LIST_IDShare a named task list across sessions
TASK_MAX_OUTPUT_LENGTHRemoved in v2.1.277; no effect

MCP

VariablePurpose
MCP_TIMEOUTServer start-up timeout (default 30000)
MCP_TOOL_TIMEOUTTool 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_TIMEOUTAbort 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_TOKENSMax 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_LENGTHMax characters of each tool description and server instructions sent to the model (default 2048; plain digits) (v2.1.280)
MCP_CONNECTION_NONBLOCKING0 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_MSHow long blocking start-up waits for the connection batch (default 5000)
CLAUDE_CODE_MCP_STARTUP_WAIT_MSHow 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_SIZELocal stdio servers connected in parallel (default 3)
MCP_REMOTE_SERVER_CONNECTION_BATCH_SIZERemote servers connected in parallel (default 20)
CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSMove long MCP calls to the background after this long (default 120000; 0 disables) (v2.1.212)
ENABLE_TOOL_SEARCHTool 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_SERVERSfalse stops fetching claude.ai connectors; per project or org, use disableClaudeAiConnectors
MCP_CLIENT_SECRETOAuth client secret for pre-configured credentials
MCP_OAUTH_CALLBACK_PORTFixed OAuth callback port
CLAUDE_CODE_MCP_ALLOWLIST_ENVStart stdio servers with only a safe baseline environment plus their own env
MCP_DISCOVERY_CACHE1/0 to turn the discovery cache on or off (off by default unless rolled out to you)
MCP_DISCOVERY_CACHE_TTL_SUse a cache entry without refreshing for this long (default 900)
MCP_DISCOVERY_CACHE_MAX_STALE_SDiscard entries older than this (default 14400; max 7 days)
MCP_DISCOVERY_CACHE_STRIKESFailed background refreshes tolerated before discarding (default 1) (v2.1.238)
MCP_PROTOCOL_NEGOTIATIONv2 runtime only: auto probes HTTP, connector and stdio servers for protocol 2026-07-28; legacy probes none (v2.1.221)
MCP_SDK_GENERATIONPin 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_PREFIXSDK only: drop the mcp__<server>__ prefix from SDK-created server tools

See MCP for how these interact.

Subagents, background work and workflows

VariablePurpose
CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTSRunning subagents per session before the Agent tool refuses (default 20; plain digits) (v2.1.217)
CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTHNesting depth below the main conversation (default 3; 1 disables nesting) (v2.1.217)
CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSIONRemoved in v2.1.224; no effect
CLAUDE_CODE_FORK_SUBAGENTFork mode: on interactively by default; 1 also in -p and the SDK, 0 off everywhere
CLAUDE_CODE_DISABLE_EXPLORE_PLAN_AGENTSRemove the built-in Explore and Plan subagents (v2.1.198)
CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS-p only: remove every built-in subagent type, including general-purpose, so calls without subagent_type fail
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS1 enables agent teams
CLAUDE_CODE_TEAM_TEARDOWN_PARK_TIMEOUT_MSHow long a non-interactive session waits at exit for its team to tear down (1000 to 60000; default 10000)
CLAUDE_CODE_DISABLE_BACKGROUND_TASKSDisable all background tasks: run_in_background, auto-backgrounding and Ctrl+B
CLAUDE_AUTO_BACKGROUND_TASKS1 moves long-running subagents to the background after about two minutes, and long MCP calls in -p
CLAUDE_CODE_WORKER_CHECKIN_SCHEDULEWith the above, seconds between reminders to check on background subagents, e.g. 600,1800,3600 (last value repeats) (v2.1.283)
CLAUDE_CODE_AUTO_BACKGROUND_WORKER_CHECKIN_SECONDSRemoved in v2.1.283; use the above
CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAPDo not stop background shells under memory pressure (macOS and Linux)
CLAUDE_CODE_BG_TASKS_REPORT_RUNNING0 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_MSIn -p, the idle wait ceiling for background work after the final turn (default 600000; 0 waits forever)
CLAUDE_CODE_DISABLE_AGENT_VIEWTurn off background agents and agent view (claude agents, --bg, /background, supervisor); same as disableAgentView
CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFFStop 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_ADOPTStop in-flight work (after confirming) instead of carrying it over when you background a session (v2.1.195)
CLAUDE_CODE_DISABLE_WORKFLOWSTurn off workflows; same as disableWorkflows
CLAUDE_CODE_WORKFLOW_MAX_CONCURRENT_AGENTSAgents a workflow run executes at once (1 to 256; default up to 16) (v2.1.269)
CLAUDE_CODE_DISABLE_CRONDisable scheduled tasks and /loop, including ones already scheduled
CLAUDE_CODE_GOAL_CHECKIN_MINUTESMinutes background work may hold a goal before Claude checks on it (default 30; 0 off; max 10080)

Plugins and skills

VariablePurpose
CLAUDE_CODE_PLUGIN_CACHE_DIRPlugins root (default ~/.claude/plugins); despite the name it is the parent of the cache
CLAUDE_CODE_PLUGIN_SEED_DIRRead-only seed directories (: or ; separated) for containers; see Manage plugins for your organisation
CLAUDE_CODE_PLUGIN_DIRSPlugin folders to load as if passed with --plugin-dir; absolute or ~ paths only (v2.1.280)
CLAUDE_CODE_PLUGIN_DIR_WATCHHot-reload mods loaded with --plugin-dir (on interactively; 1 everywhere, 0 off) (v2.1.287)
CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MSMarketplace clone and refresh timeout (default 120000)
CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILUREKeep the existing checkout instead of re-cloning when the remote is unreachable
CLAUDE_CODE_PLUGIN_PREFER_HTTPSClone GitHub shorthand over HTTPS, for machines without a GitHub SSH key
CLAUDE_CODE_SYNC_PLUGIN_INSTALLIn -p, wait for plugin installs before the first query
CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MSBound on that wait (no default)
CLAUDE_CODE_ENABLE_BACKGROUND_PLUGIN_REFRESHIn -p, refresh plugin state at turn boundaries after background installs (invalidates the cache for that turn)
CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALLSkip auto-registering the official marketplace, permanently once skipped
FORCE_AUTOUPDATE_PLUGINSKeep plugin auto-update on when DISABLE_AUTOUPDATER is set
CLAUDE_CODE_DISABLE_BUNDLED_SKILLSRemove bundled skills and workflows; built-in commands stay typable but hidden from the model. Same as disableBundledSkills
CLAUDE_CODE_DISABLE_POLICY_SKILLSSkip the system-wide managed skills directory
CLAUDE_CODE_SYNC_SKILLSIn -p, download your claude.ai skills and wait for the list before the first query
CLAUDE_CODE_SYNC_SKILLS_WAIT_TIMEOUT_MSThat wait (default 5000)
CLAUDE_CODE_SYNC_SKILLS_INSTALL_TIMEOUT_MSMid-session skills resync timeout for SDK reloads (default 30000)

Sessions, history and configuration

VariablePurpose
CLAUDE_CONFIG_DIRConfiguration 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_NAMEWith 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_TMPDIRTemp directory base (Claude Code appends /claude-{uid}/ or /claude/). Not settable from project or local settings
CLAUDE_CODE_SKIP_PROMPT_HISTORYDo not write prompt history or transcripts; sessions do not appear in resume or history
CLAUDE_CODE_FORCE_SESSION_PERSISTENCEPersist and register sessions even when an inherited CLAUDE_CODE_CHILD_SESSION makes a top-level session look nested
CLAUDE_CODE_TRANSCRIPT_LOCAL_GCIn 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_TURNResume automatically if the last session ended mid-turn (SDK use)
CLAUDE_CODE_RESUME_INTERRUPTED_TURN_MAX_AGE_MSSkip 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_PROMPTContinuation message for those resumes and deferred tool calls; default Continue from where you left off.
CLAUDE_CODE_EXIT_AFTER_STOP_DELAYExit automatically this many ms after the query loop goes idle (SDK scripts)
CLAUDE_CODE_MAX_TURNSDefault turn cap when none is passed; --max-turns wins; invalid values error at start-up
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MDLoad CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md and CLAUDE.local.md from --add-dir directories
CLAUDE_CODE_DISABLE_CLAUDE_MDSLoad no CLAUDE.md files at all, user, project or memory
CLAUDE_CODE_DISABLE_AUTO_MEMORY1 disables auto memory; 0 forces it on even under --bare or autoMemoryEnabled: false
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONSRemove built-in commit/PR instructions and the git status snapshot; beats includeGitInstructions
CLAUDE_CODE_NEW_INITMake /init an interactive flow covering CLAUDE.md, skills and hooks
CLAUDE_CODE_SIMPLESame 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_MODESame as --safe-mode; inherited by direct child processes
CLAUDE_CODE_RESTRICTEDSame as --restricted; ignored in settings env (v2.1.248)
CLAUDE_CODE_EMIT_SESSION_STATE_EVENTSAdd session_state_changed messages to the SDK or stream-json output
CLAUDE_CODE_STARTUP_FAILURE_RESULTSWith stream-json output, write a result message explaining start-up refusals (v2.1.274)
CLAUDE_CODE_FORWARD_SUBAGENT_TEXTSame as --forward-subagent-text, but silently ignored outside stream-json -p (v2.1.211)
CLAUDE_CODE_USER_DIALOG_TIMEOUT_MSDeadline 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_CAPConsecutive Stop/SubagentStop blocks allowed before the turn ends anyway (default 8; 0 disables)
CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MSTime 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_WRAPPERLauncher 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_UNIONUse 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_BUNDLEMake claude --cloud upload a bundle of your local repository instead of cloning its remote

Interface and accessibility

VariablePurpose
CLAUDE_CODE_NO_FLICKER1 enables fullscreen rendering; beats tui
CLAUDE_CODE_DISABLE_ALTERNATE_SCREENForce the classic renderer; beats CLAUDE_CODE_NO_FLICKER and tui (agent view sessions stay fullscreen)
CLAUDE_CODE_ALT_SCREEN_FULL_REPAINTRepaint fully every frame in fullscreen if you see stale fragments
CLAUDE_CODE_DISABLE_VIRTUAL_SCROLLRender every message in fullscreen if scrolling shows blanks
CLAUDE_CODE_DISABLE_MOUSENo mouse tracking in fullscreen; keeps native copy-on-select
CLAUDE_CODE_DISABLE_MOUSE_CLICKSKeep wheel scrolling but ignore clicks and hover (v2.1.195)
CLAUDE_CODE_SCROLL_SPEEDWheel multiplier, up to 20 (fractions allowed); ignored in JetBrains' terminal
CLAUDE_CODE_NATIVE_CURSORUse the terminal's own cursor at the caret
CLAUDE_CODE_ACCESSIBILITYKeep the native cursor visible for screen magnifiers
CLAUDE_AX_SCREEN_READER1 for screen-reader output, 0 forces it off; --ax-screen-reader wins. See Accessibility
CLAUDE_AX_STARTUP_QUIET_MSHold the first render after start-up so a screen reader can finish (default 3000; max 600000)
CLAUDE_AX_PREPARK_MSDelay before writing changed lines in screen reader mode (default 0; max 5000)
CLAUDE_CODE_FORCE_SYNC_OUTPUTForce synchronised output (DEC mode 2026) for undetected terminals such as Emacs eat; no effect in tmux
CLAUDE_CODE_NONBLOCKING_STDOUTWrite output through a non-blocking descriptor so a stalled terminal cannot freeze Claude Code (v2.1.261)
CLAUDE_CODE_TMUX_TRUECOLORPresence-only: allow 24-bit colour in tmux (after adding Tc to your tmux config)
CLAUDE_CODE_FORCE_STRIKETHROUGHRender ~~text~~ as strikethrough on undetected terminals
CLAUDE_CODE_FORCE_TERMINAL_IMAGESDraw mod Image elements on undetected kitty-graphics terminals
FORCE_HYPERLINK1 forces OSC 8 links on, 0 off (numeric)
CLAUDE_CODE_SYNTAX_HIGHLIGHTfalse disables diff highlighting (syntaxHighlightingDisabled covers code blocks too)
CLAUDE_CODE_BS_AS_CTRL_BACKSPACEHow to read ^H: 0 plain Backspace, 1 Ctrl+Backspace (defaults differ on Windows)
CLAUDE_CODE_DISABLE_TERMINAL_TITLEStop updating the terminal title and generating session titles
CLAUDE_CODE_HIDE_CWDHide the working directory in the start-up logo, for screen shares
IS_DEMOPresence-only demo mode: hides email and organisation, skips onboarding
CLAUDE_CODE_ENABLE_PROMPT_SUGGESTIONfalse disables prompt suggestions; true keeps them on near usage limits. Beats promptSuggestionEnabled (v2.1.238)
CLAUDE_CODE_ENABLE_AWAY_SUMMARYForce session recap off (0) or on (1)
CLAUDE_AFK_TIMEOUT_MSDemo/test override that turns on AskUserQuestion auto-continue after this idle time; 0 closes immediately (v2.1.198)
CLAUDE_AFK_COUNTDOWN_MSWhen the auto-continue countdown appears (default 20000)
CLAUDE_CODE_AUTO_CONNECT_IDEfalse prevents IDE auto-connect, true forces an attempt; beats autoConnectIde
CLAUDE_CODE_IDE_HOST_OVERRIDEHost address for the IDE connection
CLAUDE_CODE_IDE_SKIP_AUTO_INSTALLDo not auto-install IDE extensions
CLAUDE_CODE_IDE_SKIP_VALID_CHECKSkip IDE lockfile validation when auto-connect cannot find a running IDE
CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIXPrefix for generated Remote Control names (default hostname)
CLAUDE_CLIENT_PRESENCE_FILEWhile this file exists (created by your screen-unlock tooling), Remote Control mobile pushes are skipped
CLAUDE_CODE_DISABLE_NOTIFICATION_PRESENCE_CHECKSend PushNotification desktop alerts even while you are active at the terminal (v2.1.193)
CLAUDE_CODE_ARTIFACT_AUTO_OPEN0 stops opening the browser for new artifacts
CLAUDE_CODE_ARTIFACT_COMMENTS0 stops Claude reading and replying to artifact comments (v2.1.221)
CLAUDE_CODE_ARTIFACT_COMMENTS_AUTOREACT0 stops Claude replying to comments on its own (v2.1.228)

Switching features off

VariableWhat it removes
CLAUDE_CODE_DISABLE_FAST_MODEFast mode
CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORSNot 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_CHECKNot 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_TOOLThe advisor; --advisor is accepted but ignored
CLAUDE_CODE_DISABLE_ARTIFACTThe Artifact tool, irreversibly for that session (settings: enableArtifact: false)
CLAUDE_CODE_DISABLE_CFC_PROMPTThe 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_OTELRoute those surveys to your own OTel collector when Anthropic-bound traffic is blocked
CLAUDE_CODE_SEND_FEEDBACK0 disables Claude-drafted feedback for the session
DISABLE_FEEDBACK_COMMAND/feedback, /bug, /share and drafted feedback (old name DISABLE_BUG_COMMAND accepted)
DISABLE_DOCTOR_COMMANDThe /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_WARNINGSCost warning messages
DISABLE_INSTALLATION_CHECKSInstallation warnings (only if you manage the install location yourself)
CLAUDE_CODE_ENABLE_AUTO_MODENothing; accepted for compatibility (auto mode is available everywhere)
CLAUDE_CODE_AUTO_MODE_SERVER0 uses local classifier requests instead of server-side review (v2.1.271)

Updates, telemetry and privacy

VariablePurpose
DISABLE_AUTOUPDATERStop background updates (and plugin auto-update unless forced); claude update still works
DISABLE_UPDATESBlock all updates, manual included
CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATELet Claude Code run Homebrew or WinGet upgrades in the background
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICPresence-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_TELEMETRYPresence-only telemetry opt-out (events never contain code, paths or commands); also disables feature flags
DO_NOT_TRACKSame effect, but a normal boolean, so 0 leaves telemetry on
DISABLE_ERROR_REPORTINGPresence-only error reporting opt-out
DISABLE_GROWTHBOOK1 or true disables feature-flag fetching and uses code defaults; 0/false leaves fetching on
DEBUG1, true, yes or on enables debug mode (patterns like express:* do not)
CLAUDE_CODE_DEBUG_LOGS_DIRDebug log file path (despite the name); needs debug mode enabled separately
CLAUDE_CODE_DEBUG_LOG_LEVELverbose, debug (default), info, warn or error

OpenTelemetry

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.

VariablePurpose
CLAUDE_CODE_ENABLE_TELEMETRY1 enables OTel collection; required before exporters
Standard OTEL_* exporter variablesOTEL_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_PROMPTSInclude prompt text (redacted by default)
OTEL_LOG_ASSISTANT_RESPONSESInclude response text; defaults to the prompts setting, 0 keeps it redacted (v2.1.193)
OTEL_LOG_TOOL_DETAILSInclude 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_CONTENTInclude tool content on the tool.output span event (needs tracing)
OTEL_LOG_RAW_API_BODIES1 for inline request/response bodies, or file:<dir> to write them untruncated and log a body_ref
OTEL_LOG_MANAGED_SETTINGSAdd redacted managed settings and a pre-redaction digest to managed_settings_resolved events (v2.1.274)
OTEL_METRICS_INCLUDE_SESSION_IDfalse drops session id (included by default)
OTEL_METRICS_INCLUDE_ACCOUNT_UUIDfalse drops account UUID (included)
OTEL_METRICS_INCLUDE_VERSIONtrue adds the version (excluded)
OTEL_METRICS_INCLUDE_ENTRYPOINTtrue adds the entrypoint (excluded)
OTEL_METRICS_INCLUDE_REPOSITORYtrue adds vcs.* repository attributes (v2.1.269)
OTEL_METRICS_INCLUDE_RESOURCE_ATTRIBUTESfalse stops copying resource attributes to datapoint labels
OTEL_ATTRIBUTE_VALUE_LENGTH_LIMITSDK attribute limit; content attributes use the smaller of this and the next variable (log and span variants read too)
CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTHMax length of content-bearing attributes (default 61440 UTF-16 units)
CLAUDE_CODE_OTEL_DIAG_STDERRPrint exporter errors to stderr (otherwise only with --debug)
CLAUDE_CODE_OTEL_FLUSH_TIMEOUT_MSSpan flush timeout (default 5000)
CLAUDE_CODE_OTEL_SHUTDOWN_TIMEOUT_MSExporter shutdown timeout (default 2000)
CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MSDynamic header refresh interval (default 1740000)
ENABLE_BETA_TRACING_DETAILEDWith BETA_TRACING_ENDPOINT, detailed beta tracing; interactive CLI needs an allowlisted organisation
BETA_TRACING_ENDPOINTOTLP/HTTP endpoint for detailed tracing

Security hardening

VariablePurpose
CLAUDE_CODE_SUBPROCESS_ENV_SCRUBStrip credentials from subprocess environments; see below
CLAUDE_CODE_SCRIPT_CAPSWith 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_TIMEOUTRemove 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_PROMPTStop 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_PROMPTStop reading bash -c '...' scripts for critical-path removals. Launch environment only (v2.1.288)
CLAUDE_CODE_DISABLE_POWERSHELL_CMD_RM_DENYDisable the PowerShell deny for rd, rmdir, del and erase on system paths; ignored in settings env (v2.1.283)
CLAUDE_CODE_DISABLE_PERMISSION_PROMPT_NOTIFY_HOOKSDo not run Notification hooks for permission requests routed to an SDK canUseTool callback (desktop and VS Code) (v2.1.233)

See Permission modes for what counts as a critical path.

The subprocess credential scrub

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.

ExampleResult
ANTHROPIC_API_KEY, AWS_SECRET_ACCESS_KEYRemoved
NPM_TOKEN, DB_PASSWORDRemoved (name looks like a credential)
DATABASE_URL with an embedded passwordRemoved (value looks like a credential)
PIP_INDEX_URL or NPM_CONFIG_REGISTRY with embedded credentialsKept, with the username and password cut out
CLAUDE_CONFIG_DIRRemoved
GITHUB_TOKEN, GH_TOKEN, GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKENKept so gh keeps working
HTTP_PROXY, HTTPS_PROXYKept, credentials included
GIT_CONFIG_COUNT, GIT_CONFIG_KEY_<n>, GIT_CONFIG_VALUE_<n>Kept
A secret with an innocent name and valueKept

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.

VariableMeaning
CLAUDECODE1 in subprocesses Claude Code spawns (tools, tmux, hooks, status line, stdio MCP servers), and in IDE-integrated terminals
CLAUDE_CODE_CHILD_SESSION1 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_IDCurrent session id in tool, hook and stdio MCP subprocesses; updated on /clear for tools and hooks
CLAUDE_CODE_BRIDGE_SESSION_IDThe session_... id while Remote Control is connected (v2.1.199)
CLAUDE_CODE_REMOTEtrue in cloud sessions
CLAUDE_CODE_REMOTE_SESSION_IDSession id in cloud sessions, for linking back to the transcript
CLAUDE_EFFORTEffort level at subprocess start, when the model supports effort
CLAUDE_PIDClaude Code's process id, in tool and hook subprocesses (v2.1.214)
CLAUDE_JOB_DIRA background session's ~/.claude/jobs/<id> folder; scratch files go in $CLAUDE_JOB_DIR/tmp
CLAUDE_CODE_MESSAGING_SOCKETInbox socket path for cross-session messaging (v2.1.224)
CLAUDE_CODE_MESSAGING_TOKENPer-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.