Skip to main content
Claude Code reads a number of environment variables at startup and throughout a session. These complement settings.json for cases where you need machine- or process-level control without modifying files.
ANTHROPIC_API_KEY is required when authenticating via API key. Without it (and without an active OAuth session), Claude Code cannot make API calls.

Authentication

VariableDefaultDescription
ANTHROPIC_API_KEYAnthropic API key used for direct authentication
ANTHROPIC_BASE_URLOverride the Anthropic API base URL
ANTHROPIC_UNIX_SOCKETConnect to the Anthropic API over a Unix domain socket
CLAUDE_CODE_OAUTH_TOKENOAuth bearer token injected by the calling environment
AWS_BEARER_TOKEN_BEDROCKBearer token for AWS Bedrock authentication

Cloud provider routing

VariableDefaultDescription
CLAUDE_CODE_USE_BEDROCKRoute requests through AWS Bedrock
CLAUDE_CODE_USE_VERTEXRoute requests through Google Cloud Vertex AI
CLAUDE_CODE_USE_FOUNDRYRoute requests through Microsoft Azure AI Foundry
AWS_REGIONus-east-1AWS region for Bedrock requests
AWS_DEFAULT_REGIONus-east-1Fallback AWS region when AWS_REGION is not set
ANTHROPIC_BEDROCK_BASE_URLOverride the Bedrock endpoint base URL
CLOUD_ML_REGIONus-east5Default Vertex AI region
CLAUDE_CODE_SKIP_BEDROCK_AUTHSkip Bedrock authentication checks

Vertex AI per-model region overrides

Each variable below pins a specific model to a Vertex AI region:
VariableModel prefix
VERTEX_REGION_CLAUDE_HAIKU_4_5claude-haiku-4-5
VERTEX_REGION_CLAUDE_3_5_HAIKUclaude-3-5-haiku
VERTEX_REGION_CLAUDE_3_5_SONNETclaude-3-5-sonnet
VERTEX_REGION_CLAUDE_3_7_SONNETclaude-3-7-sonnet
VERTEX_REGION_CLAUDE_4_0_SONNETclaude-sonnet-4
VERTEX_REGION_CLAUDE_4_5_SONNETclaude-sonnet-4-5
VERTEX_REGION_CLAUDE_4_6_SONNETclaude-sonnet-4-6
VERTEX_REGION_CLAUDE_4_0_OPUSclaude-opus-4
VERTEX_REGION_CLAUDE_4_1_OPUSclaude-opus-4-1

Configuration paths

VariableDefaultDescription
CLAUDE_CONFIG_DIR~/.claudeOverride the Claude configuration home directory

Operational modes

VariableDefaultDescription
CLAUDE_CODE_SIMPLEEnable bare/simple mode: skips hooks, LSP, plugin sync, skill directory walk, attribution, background prefetches, and all keychain reads. Auth is strictly ANTHROPIC_API_KEY or apiKeyHelper. Equivalent to the --bare CLI flag
CLAUDE_CODE_REMOTEEnable remote container mode; sets max-old-space-size=8192 and enables all hook events
CLAUDE_CODE_REMOTE_SESSION_IDSession ID for the current remote session
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICDisable non-essential network traffic (analytics, telemetry, etc.)
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETASDisable experimental beta API features

Memory

VariableDefaultDescription
CLAUDE_CODE_DISABLE_AUTO_MEMORYDisable the auto-memory system entirely. Set to 1 or true to turn off; 0 or false to force-enable even when autoMemoryEnabled: false is in settings
CLAUDE_CODE_REMOTE_MEMORY_DIROverride the base directory for remote session memory storage
CLAUDE_COWORK_MEMORY_PATH_OVERRIDEFull-path override for the auto-memory directory (used by Cowork/SDK)
CLAUDE_COWORK_MEMORY_EXTRA_GUIDELINESExtra memory policy text injected into memory prompts

Context and compaction

VariableDefaultDescription
DISABLE_COMPACTDisable context compaction entirely
DISABLE_AUTO_COMPACTDisable automatic context compaction (manual compact still works)
DISABLE_BACKGROUND_TASKSDisable background task execution
API_MAX_INPUT_TOKENSOverride the maximum input token limit
API_TARGET_INPUT_TOKENSOverride the target input token count for compaction

Thinking and model behavior

VariableDefaultDescription
CLAUDE_CODE_DISABLE_THINKINGDisable extended thinking mode
DISABLE_INTERLEAVED_THINKINGDisable interleaved thinking

Telemetry and observability

VariableDefaultDescription
OTEL_LOG_TOOL_DETAILSSet to 1 to enable full tool input capture in OpenTelemetry telemetry
OTEL_EXPORTER_OTLP_PROTOCOLOpenTelemetry exporter protocol (e.g. grpc, http/protobuf)
NODE_EXTRA_CA_CERTSPath to extra CA certificate file for custom TLS trust roots

Shell and editor behavior

VariableDefaultDescription
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIRReset the working directory to the project root after each Bash command
CLAUDE_CODE_GIT_BASH_PATHPath to git-bash executable (Windows)
EDITOREditor to open when /memory is invoked and no $VISUAL is set
VISUALPreferred editor; takes precedence over $EDITOR
SHELLShell used for command execution

Networking

VariableDefaultDescription
CLAUDE_CODE_DISABLE_COMMAND_INJECTION_CHECKDisable the command injection safety check (not recommended)

How environment variables interact with settings

Environment variables are evaluated at the process level and take effect for the lifetime of the Claude Code process. They are not written to settings.json. The env field in settings.json lets you set environment variables that are applied to each Claude Code session:
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://my-proxy.example.com",
    "NODE_EXTRA_CA_CERTS": "/etc/ssl/my-ca-bundle.crt"
  }
}
Truthy values for boolean environment variables are 1, true, yes, and on (case-insensitive). Falsy values are 0, false, no, and off. An unset variable is treated as falsy.

Build docs developers (and LLMs) love