Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Appendix B: Environment Variable Reference

This appendix lists the key user-configurable environment variables in Claude Code v2.1.88. Grouped by functional domain, only variables affecting user-visible behavior are listed; internal telemetry and platform detection variables are omitted.

Context Compaction

VariableEffectDefault
CLAUDE_CODE_AUTO_COMPACT_WINDOWOverride context window size (tokens)Model default
CLAUDE_AUTOCOMPACT_PCT_OVERRIDEOverride auto-compaction threshold as percentage (0-100)Computed value
DISABLE_AUTO_COMPACTCompletely disable auto-compactionfalse

Effort and Reasoning

VariableEffectValid Values
CLAUDE_CODE_EFFORT_LEVELOverride effort levellow, medium, high, max, auto, unset
CLAUDE_CODE_DISABLE_FAST_MODEDisable Fast Mode accelerated outputtrue/false
DISABLE_INTERLEAVED_THINKINGDisable extended thinkingtrue/false
MAX_THINKING_TOKENSOverride thinking token limitModel default

Tools and Output Limits

VariableEffectDefault
BASH_MAX_OUTPUT_LENGTHMax output characters for Bash commands8,000
CLAUDE_CODE_GLOB_TIMEOUT_SECONDSGlob search timeout (seconds)Default

Permissions and Security

VariableEffectNote
CLAUDE_CODE_DUMP_AUTO_MODEExport YOLO classifier requests/responsesDebug only
CLAUDE_CODE_DISABLE_COMMAND_INJECTION_CHECKDisable Bash command injection detectionReduces security

API and Authentication

VariableEffectSecurity Level
ANTHROPIC_API_KEYAnthropic API authentication keyCredential
ANTHROPIC_BASE_URLCustom API endpoint (proxy support)Redirectable
ANTHROPIC_MODELOverride default modelSafe
CLAUDE_CODE_USE_BEDROCKRoute inference through AWS BedrockSafe
CLAUDE_CODE_USE_VERTEXRoute inference through Google Vertex AISafe
CLAUDE_CODE_EXTRA_BODYAppend extra fields to API requestsAdvanced use
ANTHROPIC_CUSTOM_HEADERSCustom HTTP request headersSafe

Model Selection

VariableEffectExample
ANTHROPIC_DEFAULT_HAIKU_MODELCustom Haiku model IDModel string
ANTHROPIC_DEFAULT_SONNET_MODELCustom Sonnet model IDModel string
ANTHROPIC_DEFAULT_OPUS_MODELCustom Opus model IDModel string
ANTHROPIC_SMALL_FAST_MODELFast inference model (e.g., for summaries)Model string
CLAUDE_CODE_SUBAGENT_MODELModel used by sub-AgentsModel string

Prompt Caching

VariableEffectDefault
CLAUDE_CODE_ENABLE_PROMPT_CACHINGEnable prompt cachingtrue
DISABLE_PROMPT_CACHINGCompletely disable prompt cachingfalse

Session and Debugging

VariableEffectPurpose
CLAUDE_CODE_DEBUG_LOG_LEVELLog verbositysilent/error/warn/info/verbose
CLAUDE_CODE_PROFILE_STARTUPEnable startup performance profilingDebug
CLAUDE_CODE_PROFILE_QUERYEnable query pipeline profilingDebug
CLAUDE_CODE_JSONL_TRANSCRIPTWrite session transcript as JSONLFile path
CLAUDE_CODE_TMPDIROverride temporary directoryPath

Output and Formatting

VariableEffectDefault
CLAUDE_CODE_SIMPLEMinimal system prompt modefalse
CLAUDE_CODE_DISABLE_TERMINAL_TITLEDisable setting terminal titlefalse
CLAUDE_CODE_NO_FLICKERReduce fullscreen mode flickeringfalse

MCP (Model Context Protocol)

VariableEffectDefault
MCP_TIMEOUTMCP server connection timeout (ms)10,000
MCP_TOOL_TIMEOUTMCP tool call timeout (ms)30,000
MAX_MCP_OUTPUT_TOKENSMCP tool output token limitDefault

Network and Proxy

VariableEffectNote
HTTP_PROXY / HTTPS_PROXYHTTP/HTTPS proxyRedirectable
NO_PROXYHost list to bypass proxySafe
NODE_EXTRA_CA_CERTSAdditional CA certificatesAffects TLS trust

Paths and Configuration

VariableEffectDefault
CLAUDE_CONFIG_DIROverride Claude configuration directory~/.claude

Version Evolution: v2.1.91 New Variables

VariableEffectNotes
CLAUDE_CODE_AGENT_COST_STEERSub-agent cost steeringControls resource consumption in multi-agent scenarios
CLAUDE_CODE_RESUME_THRESHOLD_MINUTESSession resume time thresholdControls the time window for session resumption
CLAUDE_CODE_RESUME_TOKEN_THRESHOLDSession resume token thresholdControls the token budget for session resumption
CLAUDE_CODE_USE_ANTHROPIC_AWSAWS authentication pathEnables Anthropic AWS infrastructure authentication
CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTHSkip AWS authenticationFallback path when AWS is unavailable
CLAUDE_CODE_DISABLE_CLAUDE_API_SKILLDisable Claude API skillEnterprise compliance scenario control
CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILUREPlugin marketplace fault toleranceRetain cached version when marketplace fetch fails
CLAUDE_CODE_REMOTE_SETTINGS_PATHRemote settings path overrideCustom settings URL for enterprise deployment

v2.1.91 Removed Variables

VariableOriginal EffectRemoval Reason
CLAUDE_CODE_DISABLE_COMMAND_INJECTION_CHECKDisable command injection checkTree-sitter infrastructure entirely removed
CLAUDE_CODE_DISABLE_MOUSE_CLICKSDisable mouse clicksFeature deprecated
CLAUDE_CODE_MCP_INSTR_DELTAMCP instruction deltaFeature refactored

Configuration Priority System

Environment variables are just one facet of Claude Code's configuration system. The complete configuration system is composed of 6 layers of sources, merged from lowest to highest priority — later sources override earlier ones. Understanding this priority chain is crucial for diagnosing "why isn't my setting taking effect."

Six-Layer Priority Model

Configuration sources are defined in restored-src/src/utils/settings/constants.ts:7-22, and the merge logic is implemented in the loadSettingsFromDisk() function at restored-src/src/utils/settings/settings.ts:644-796:

PrioritySource IDFile Path / SourceDescription
0 (lowest)pluginSettingsPlugin-provided base settingsOnly includes whitelisted fields (e.g., agent), serves as the base layer for all file sources
1userSettings~/.claude/settings.jsonUser global settings, applies across all projects
2projectSettings$PROJECT/.claude/settings.jsonProject shared settings, committed to version control
3localSettings$PROJECT/.claude/settings.local.jsonProject local settings, automatically added to .gitignore
4flagSettings--settings CLI parameter + SDK inline settingsTemporary overrides passed via command line or SDK
5 (highest)policySettingsEnterprise managed policies (multiple competing sources)Enterprise admin enforced policies, see below

Merge Semantics

Merging uses lodash's mergeWith for deep merge, with a custom merger defined at restored-src/src/utils/settings/settings.ts:538-547:

  • Objects: Recursively merged, later source fields override earlier ones
  • Arrays: Merged and deduplicated (mergeArrays), not replaced — this means permissions.allow rules from multiple layers accumulate
  • undefined values: Interpreted as "delete this key" in updateSettingsForSource (restored-src/src/utils/settings/settings.ts:482-486)

This array merge semantic is particularly important: if a user allows a tool in userSettings and allows another tool in projectSettings, the final permissions.allow list includes both. This enables multi-layer permission configurations to stack rather than override each other.

Policy Settings (policySettings) Four-Layer Competition

Policy settings (policySettings) have their own internal priority chain, using a "first source with content wins" strategy, implemented at restored-src/src/utils/settings/settings.ts:322-345:

Sub-prioritySourceDescription
1 (highest)Remote Managed SettingsEnterprise policy cache synced from API
2MDM Native Policies (HKLM / macOS plist)System-level policies read via plutil or reg query
3File Policies (managed-settings.json + managed-settings.d/*.json)Drop-in directory support, merged in alphabetical order
4 (lowest)HKCU User Policies (Windows only)User-level registry settings

Note that policy settings merge differently from other sources: the four sub-sources within policies are in a competitive relationship (first one wins), while policies as a whole are in an additive relationship with other sources (deep merged to the top of the configuration chain).

Override Chain Flowchart

flowchart TD
    P["pluginSettings<br/>Plugin base settings"] -->|mergeWith| U["userSettings<br/>~/.claude/settings.json"]
    U -->|mergeWith| Proj["projectSettings<br/>.claude/settings.json"]
    Proj -->|mergeWith| L["localSettings<br/>.claude/settings.local.json"]
    L -->|mergeWith| F["flagSettings<br/>--settings CLI / SDK inline"]
    F -->|mergeWith| Pol["policySettings<br/>Enterprise managed policies"]
    Pol --> Final["Final effective config<br/>getInitialSettings()"]

    subgraph PolicyInternal["policySettings internal competition (first wins)"]
        direction TB
        R["Remote Managed<br/>Remote API"] -.->|empty?| MDM["MDM Native<br/>plist / HKLM"]
        MDM -.->|empty?| MF["File Policies<br/>managed-settings.json"]
        MF -.->|empty?| HK["HKCU<br/>Windows user-level"]
    end

    Pol --- PolicyInternal

    style Final fill:#e8f4f8,stroke:#2196F3,stroke-width:2px
    style PolicyInternal fill:#fff3e0,stroke:#FF9800

Figure B-1: Configuration Priority Override Chain

Caching and Invalidation

Configuration loading has a two-layer caching mechanism (restored-src/src/utils/settings/settingsCache.ts):

  1. File-level cache: parseSettingsFile() caches the parsed result of each file, avoiding repeated JSON parsing
  2. Session-level cache: getSettingsWithErrors() caches the merged final result, reused throughout the session

Caches are uniformly invalidated via resetSettingsCache() — triggered when the user modifies settings through the /config command or updateSettingsForSource(). Settings file change detection is handled by restored-src/src/utils/settings/changeDetector.ts, which drives React component re-rendering through file system watching.

Diagnostic Recommendations

When a setting "isn't taking effect," troubleshoot in this order:

  1. Confirm the source: Use the /config command to view the current effective configuration and source annotations
  2. Check priority: Is a higher-priority source overriding your setting? policySettings is the strongest override
  3. Check array merging: Permission rules are additive — if a deny rule appears in a higher-priority source, a lower-priority allow cannot override it
  4. Check caching: After modifying .json files within the same session, the configuration may still be cached — restart the session or use /config to trigger a refresh