/model.
This page covers how to:
- Set environment variables in your shell or in a settings file
- Check which value applies when a behavior can be set more than one way
- Look up the variables Claude Code reads
- See which features stop working when a variable turns feature-flag fetching off
Set environment variables
A variable you set in your shell lasts for that terminal session, while a variable in a settings file applies every timeclaude runs.
In your shell
Set the variable before launchingclaude:
- macOS, Linux, WSL
- Windows PowerShell
- Windows CMD
export API_TIMEOUT_MS="1200000"
claude
export line to ~/.bashrc, ~/.zshrc, or your shell’s profile file.$env:API_TIMEOUT_MS = "1200000"
claude
[Environment]::SetEnvironmentVariable("API_TIMEOUT_MS", "1200000", "User") and open a new terminal.set API_TIMEOUT_MS=1200000
claude
setx API_TIMEOUT_MS "1200000" and open a new terminal.claude:
- macOS, Linux, WSL
- Windows PowerShell
- Windows CMD
echo $API_TIMEOUT_MS
echo $env:API_TIMEOUT_MS
echo %API_TIMEOUT_MS%
In settings files
Add variables under theenv key in a settings.json file, creating the file if it doesn’t exist. Claude Code reads them directly from the file, so they take effect no matter how claude was launched. A running session applies new and changed values to its environment when you save the file, but a feature that reads its variables once at startup, such as OpenTelemetry monitoring, keeps its startup values until you relaunch. Removing a variable from the file doesn’t unset it in a running session; the removal takes effect the next time you launch claude.
~/.claude/settings.json
{
"env": {
"API_TIMEOUT_MS": "1200000",
"BASH_DEFAULT_TIMEOUT_MS": "300000"
}
}
| File | Applies to |
|---|---|
~/.claude/settings.json | You, in every project |
.claude/settings.json | Everyone working in the project, checked into source control |
.claude/settings.local.json | You, in this project only, gitignored when Claude Code saves a setting to it; add it to your gitignore if you create it by hand |
| Managed settings | Everyone in your organization, deployed by an admin |
Precedence
Some behaviors have both an environment variable and a dedicated settings key, and which one Claude Code reads first differs per key. ForANTHROPIC_MODEL and CLAUDE_CODE_AUTO_CONNECT_IDE, Claude Code reads the variable first and uses the model or autoConnectIde setting only when the variable is unset. For the pair you’re setting, check the variable’s row below and the key’s entry on the settings reference.
When the same variable is set in both your shell and a settings file env block, the settings file value applies. Claude Code writes each env entry into the process environment, replacing the value inherited from the shell. The env setting says when it applies them. A few variables are special-cased; the env setting lists the exceptions.
In a settings file you can set a variable but you can’t remove one. To override a variable you can’t unset, such as a stale CLAUDE_CODE_USE_VERTEX exported by a shell profile you don’t control, set it to an empty string in the env block: "CLAUDE_CODE_USE_VERTEX": "". Claude Code treats the empty value as unset for provider selection. Subprocesses still inherit the empty value.
Between settings files, env values follow settings precedence, so a managed settings entry overrides the same variable in user or project settings.
How an environment variable interacts with CLI flags and in-session commands varies per feature: --model and /model override ANTHROPIC_MODEL, while CLAUDE_CODE_EFFORT_LEVEL overrides --effort and /effort. When a variable interacts with another configuration source, its row in the Variables list states the precedence or links to the page that documents it.
Claude Code reads shell environment variables at startup, so changes to them take effect the next time you launch claude. Variables set under the env key in settings files are reapplied to a running session when the file changes, with the startup-only exception described in In settings files.
Variables
Numeric variables such as timeouts, token budgets, and retry counts accept scientific notation and digit-separator spellings in addition to plain digits, except where a variable’s row notes it takes plain digits only. For example, Claude Code reads2e3 as 2000 and 64_000 as 64000. Before v2.1.211, these spellings could silently set a much smaller value, such as 1e6 setting a timeout to 1.
For variables that turn a behavior on or off, set
1 or true to turn it on and 0 or false to turn it off, in any casing.Some variables read only whether you set them at all, so any non-empty value including 0 turns the behavior on, and you turn the behavior off by unsetting the variable or setting it to an empty value. These variables work that way:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICDISABLE_TELEMETRYDISABLE_ERROR_REPORTINGCLAUDE_CODE_TMUX_TRUECOLORFALLBACK_FOR_ALL_PRIMARY_MODELSIS_DEMO
FORCE_HYPERLINK reads a number, so only 0 turns it off. Each variable’s row also states its own rule.| Variable | Purpose |
|---|---|
ANTHROPIC_API_KEY | API key sent as X-Api-Key header. When set, this key is used instead of your Claude Pro, Max, Team, or Enterprise subscription even if you are logged in. In non-interactive mode (-p), the key is always used when present. In interactive mode, you are prompted to approve the key once before it overrides your subscription. To use your subscription instead, run unset ANTHROPIC_API_KEY |
ANTHROPIC_AUTH_TOKEN | Custom value for the Authorization header (the value you set here will be prefixed with Bearer ) |
ANTHROPIC_AWS_API_KEY | Workspace API key for Claude Platform on AWS, generated in the AWS Console. Sent as x-api-key and takes precedence over AWS SigV4 |
ANTHROPIC_AWS_BASE_URL | Override the Claude Platform on AWS endpoint URL. Use for custom regions or when routing through an LLM gateway. Defaults to https://aws-external-anthropic.{region}.api.aws. Claude Code resolves the region with the same precedence as on Amazon Bedrock |
ANTHROPIC_AWS_WORKSPACE_ID | Required for Claude Platform on AWS. Sent on every request as the anthropic-workspace-id header |
ANTHROPIC_BASE_URL | Override the API endpoint to route requests through a proxy or gateway. When set to a non-first-party host, MCP tool search is disabled by default. Set ENABLE_TOOL_SEARCH=true if your proxy forwards tool_reference blocks. As of v2.1.196, Remote Control is disabled when this points at a host other than api.anthropic.com, matching its behavior on Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry |
ANTHROPIC_BEDROCK_BASE_URL | Override the Amazon Bedrock endpoint URL. Use for custom Amazon Bedrock endpoints or when routing through an LLM gateway. See Amazon Bedrock |
ANTHROPIC_BEDROCK_MANTLE_BASE_URL | Override the Amazon Bedrock Mantle endpoint URL. See Mantle endpoint |
ANTHROPIC_BEDROCK_REGION_PREFIX | Cross-region inference profile prefix (us, eu, apac, jp, au, or global) Claude Code tries first instead of the one derived from the AWS region. Ignored in AWS GovCloud regions. Requires Claude Code v2.1.224 or later. See Amazon Bedrock |
ANTHROPIC_BEDROCK_SERVICE_TIER | Amazon Bedrock service tier (default, flex, or priority). Sent as the X-Amzn-Bedrock-Service-Tier header. See Amazon Bedrock |
ANTHROPIC_BETAS | Comma-separated list of additional anthropic-beta header values to include in API requests. Claude Code already sends the beta headers it needs; use this to opt into an Anthropic API beta before Claude Code adds native support. Unlike the --betas flag, which requires API key authentication, this variable works with all auth methods including Claude.ai subscription |
ANTHROPIC_CUSTOM_HEADERS | Custom headers to add to requests (Name: Value format, newline-separated for multiple headers). If a name or value contains a character an HTTP header can’t carry, such as a curly quote or a zero-width space, the request fails with an error that identifies the pair by position. Requires Claude Code v2.1.227 or later. Invalid request header value lists the exact character set and where the check runs. A value that sets a credential, org or tenant, routing, or API-behavior header, such as Authorization or Host, counts as a setting that needs approval when server-managed settings deliver it. From project or local settings, such a value follows the rules for when env values apply |
ANTHROPIC_CUSTOM_MODEL_OPTION | Model ID to add as a custom entry in the /model picker. Use this to make a non-standard or gateway-specific model selectable without replacing built-in aliases. See Model configuration |
ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION | Display description for the custom model entry in the /model picker. Defaults to Custom model (<model-id>) when not set |
ANTHROPIC_CUSTOM_MODEL_OPTION_NAME | Display name for the custom model entry in the /model picker. When not set, the entry shows the model’s name if Claude Code recognizes the ID, and the model ID otherwise |
ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIES | Comma-separated list of capabilities the custom model supports, for example effort,thinking. See Model configuration |
ANTHROPIC_DEFAULT_FABLE_MODEL | Model ID that the fable alias resolves to, and the ID Claude Code recognizes as a Fable model for automatic model fallback on third-party providers. See Model configuration |
ANTHROPIC_DEFAULT_FABLE_MODEL_DESCRIPTION | Display description for the pinned Fable model in the /model picker. When not set, the row shows a default description that begins Custom Fable model. See Model configuration |
ANTHROPIC_DEFAULT_FABLE_MODEL_NAME | Display name for the pinned Fable model in the /model picker. When not set, the row shows the model’s name if Claude Code recognizes the pinned ID, and the pinned ID otherwise. See Model configuration |
ANTHROPIC_DEFAULT_FABLE_MODEL_SUPPORTED_CAPABILITIES | Comma-separated list of capabilities the pinned Fable model supports, for example effort,thinking. See Model configuration |
ANTHROPIC_DEFAULT_HAIKU_MODEL | Model ID that the haiku alias resolves to, also used for background functionality. See Model configuration |
ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION | Display description for the pinned Haiku model in the /model picker. When not set, the row shows a default description that begins Custom Haiku model. See Model configuration |
ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME | Display name for the pinned Haiku model in the /model picker. When not set, the row shows the model’s name if Claude Code recognizes the pinned ID, and the pinned ID otherwise. See Model configuration |
ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES | Comma-separated list of capabilities the pinned Haiku model supports, for example effort,thinking. See Model configuration |
ANTHROPIC_DEFAULT_MODEL | Model that new sessions start on by default. Requires Claude Code v2.1.236 or later. See Set a default model for new sessions |
ANTHROPIC_DEFAULT_OPUS_MODEL | Model ID that the opus alias resolves to, and that opusplan uses while Plan Mode is active. See Model configuration |
ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION | Display description for the pinned Opus model in the /model picker. When not set, the row shows a default description that begins Custom Opus model. See Model configuration |
ANTHROPIC_DEFAULT_OPUS_MODEL_NAME | Display name for the pinned Opus model in the /model picker. When not set, the row shows the model’s name if Claude Code recognizes the pinned ID, and the pinned ID otherwise. See Model configuration |
ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES | Comma-separated list of capabilities the pinned Opus model supports, for example effort,thinking. See Model configuration |
ANTHROPIC_DEFAULT_SONNET_MODEL | Model ID that the sonnet alias resolves to, and that opusplan uses when Plan Mode is not active. See Model configuration |
ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION | Display description for the pinned Sonnet model in the /model picker. When not set, the row shows a default description that begins Custom Sonnet model. See Model configuration |
ANTHROPIC_DEFAULT_SONNET_MODEL_NAME | Display name for the pinned Sonnet model in the /model picker. When not set, the row shows the model’s name if Claude Code recognizes the pinned ID, and the pinned ID otherwise. See Model configuration |
ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES | Comma-separated list of capabilities the pinned Sonnet model supports, for example effort,thinking. See Model configuration |
ANTHROPIC_FEDERATION_RULE_ID | Federation rule ID for Workload Identity Federation. When you set it together with ANTHROPIC_ORGANIZATION_ID, Claude Code selects federation credentials, which rank above your /login credential. See authentication precedence |
ANTHROPIC_FOUNDRY_API_KEY | API key for Microsoft Foundry authentication (see Microsoft Foundry) |
ANTHROPIC_FOUNDRY_AUTH_TOKEN | Bearer token for Microsoft Foundry authentication, such as a Microsoft Entra access token. Claude Code sends it as the Authorization: Bearer header. Takes precedence over ANTHROPIC_FOUNDRY_API_KEY and over the Azure default credential chain. See Microsoft Foundry. Requires Claude Code v2.1.203 or later |
ANTHROPIC_FOUNDRY_BASE_URL | Full base URL for the Microsoft Foundry resource (for example, https://my-resource.services.ai.azure.com/anthropic). Alternative to ANTHROPIC_FOUNDRY_RESOURCE (see Microsoft Foundry) |
ANTHROPIC_FOUNDRY_RESOURCE | Microsoft Foundry resource name (for example, my-resource). Required if ANTHROPIC_FOUNDRY_BASE_URL is not set (see Microsoft Foundry) |
ANTHROPIC_MODEL | Name of the model setting to use (see Model Configuration) |
ANTHROPIC_ORGANIZATION_ID | Organization ID for Workload Identity Federation. Set it together with ANTHROPIC_FEDERATION_RULE_ID. See authentication precedence |
ANTHROPIC_PROFILE | Name of the Anthropic profile to authenticate with, such as one created by ant auth login or by signing in to a Console account without an API key. See authentication precedence |
ANTHROPIC_SMALL_FAST_MODEL | [DEPRECATED] Name of Haiku-class model for background tasks |
ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION | Override AWS region for the Haiku-class model when using Amazon Bedrock or Amazon Bedrock Mantle. On Amazon Bedrock, this only takes effect when ANTHROPIC_DEFAULT_HAIKU_MODEL or the deprecated ANTHROPIC_SMALL_FAST_MODEL is also set, since Amazon Bedrock otherwise runs background tasks on the default Sonnet model or the primary model in the session region |
ANTHROPIC_VERTEX_BASE_URL | Override Google Cloud’s Agent Platform endpoint URL. Use for custom Google Cloud’s Agent Platform endpoints or when routing through an LLM gateway. See Google Cloud’s Agent Platform |
ANTHROPIC_VERTEX_PROJECT_ID | GCP project ID that Google Cloud’s Agent Platform requests are addressed to. See Configure GCP credentials |
ANTHROPIC_WORKSPACE_ID | Workspace ID for workload identity federation. Set this when your federation rule is scoped to more than one workspace so the token exchange knows which workspace to target |
API_FORCE_IDLE_TIMEOUT | Override the 5-minute body idle timeout that aborts a streaming model response when no bytes arrive. Set to 0 to turn the timeout off, for example when a slow gateway or local model pauses longer than 5 minutes between chunks, or 1 to keep it on for every provider. When unset, the timeout is active on providers other than the direct Anthropic API and Claude Platform on AWS. The stream watchdogs run independently of it and abort a long silent pause even when you set 0 here |
API_TIMEOUT_MS | Timeout for API requests in milliseconds (default: 600000, or 10 minutes; maximum: 2147483647). Increase this when requests time out on slow networks or when routing through a proxy. Values above the maximum overflow the underlying timer and cause requests to fail immediately |
AWS_BEARER_TOKEN_BEDROCK | Amazon Bedrock API key for authentication (see Amazon Bedrock API keys) |
BASH_DEFAULT_TIMEOUT_MS | Default timeout for long-running bash commands (default: 120000, or 2 minutes) |
BASH_MAX_OUTPUT_LENGTH | Maximum number of characters of bash output that Claude Code reads back into a command’s result (default: 30000; maximum: 150000). If you set the bashOutputMaxChars setting, Claude Code ignores this variable. See Output limits |
BASH_MAX_TIMEOUT_MS | Maximum timeout the model can set for long-running bash commands (default: 600000, or 10 minutes). The effective ceiling is the larger of this and BASH_DEFAULT_TIMEOUT_MS |
BETA_TRACING_ENDPOINT | OTLP endpoint for detailed beta tracing: with ENABLE_BETA_TRACING_DETAILED=1, logs and traces go there instead of to the configured exporters. Set it in your shell, user settings, or managed settings. Ignored in project and local settings |
CCR_FORCE_BUNDLE | Set to 1 to force claude --cloud to bundle and upload your local repository instead of cloning from its remote |
CLAUDECODE | Set to 1 in subprocesses Claude Code spawns (Bash and PowerShell tools, tmux sessions, hook commands, status line commands, stdio MCP server subprocesses). IDE extensions also set this in their integrated terminals. Use to detect when a script is running inside a subprocess spawned by Claude Code. To check whether the current process was spawned directly by a tool call or hook, rather than inside a stdio MCP server that Claude Code started, use CLAUDE_CODE_CHILD_SESSION instead |
CLAUDE_AFK_COUNTDOWN_MS | How many milliseconds before auto-continue the on-screen countdown appears on an unanswered AskUserQuestion dialog. Default 20000 (20 seconds), capped at the auto-continue timeout. Has no effect unless auto-continue is on; see the askUserQuestionTimeout setting and CLAUDE_AFK_TIMEOUT_MS. Requires Claude Code v2.1.198 or later |
CLAUDE_AFK_TIMEOUT_MS | How many milliseconds of idle time before an unanswered AskUserQuestion dialog auto-continues without you. Auto-continue is off by default; opt in with the askUserQuestionTimeout setting. This variable is an override for demos and automated tests: when set, it takes precedence over that setting and turns auto-continue on even when the setting is unset or never. Setting 0 doesn’t turn the timeout off; it closes the dialog immediately. In v2.1.198 and v2.1.199, auto-continue was on by default with a 60000 (60 seconds) timeout. Requires Claude Code v2.1.198 or later |
CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS | Set to 1 to disable all built-in subagent types such as Explore and Plan. Only applies in non-interactive mode (the -p flag). Useful for SDK users who want a blank slate. This also removes general-purpose, the subagent Claude Code runs when an Agent tool call omits subagent_type. Such a call then fails with subagent_type is required |
CLAUDE_AGENT_SDK_MCP_NO_PREFIX | Set to 1 to skip the mcp__<server>__ prefix on tool names from SDK-created MCP servers. Tools use their original names. SDK usage only |
CLAUDE_ASYNC_AGENT_STALL_TIMEOUT_MS | Stall timeout in milliseconds for subagents. Default 600000 (10 minutes); if you raise CLAUDE_STREAM_IDLE_TIMEOUT_MS while the stream watchdog is on, the default rises with it, as Handle slow or stalled API responses describes. The timer resets on each streaming progress event; if no progress arrives within the window, Claude Code aborts the subagent and reports the stall to the parent |
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE | Set the percentage (1-100) of the auto-compact window at which auto-compaction triggers. Use lower values like 50 to compact earlier; the variable can’t raise the threshold, so values above the default percentage are ignored. It applies only in sessions that compact before the model’s context limit. Applies to both main conversations and subagents |
CLAUDE_AUTO_BACKGROUND_TASKS | Set to 1 to force-enable automatic backgrounding of long-running agent tasks. When enabled, subagents are moved to the background after running for approximately two minutes. Also enables automatic backgrounding of long MCP tool calls in non-interactive mode on Claude Code v2.1.212 or later |
CLAUDE_AX_PREPARK_MS | In screen reader mode, how many milliseconds Claude Code waits, with the cursor at the start of the line, before it writes a new or changed line. Default 50. Set 0 to write immediately. Claude Code caps the wait at 5000. Requires Claude Code v2.1.233 or later |
CLAUDE_AX_SCREEN_READER | Set to 1 to render screen-reader friendly output: flat text without decorative borders or animations. Set to 0 to force screen-reader mode off even when axScreenReader is true. The --ax-screen-reader flag takes precedence. Requires Claude Code v2.1.181 or later |
CLAUDE_AX_STARTUP_QUIET_MS | In screen reader mode, how many milliseconds Claude Code holds the first interface render after the startup confirmation line, so your screen reader can speak the line in full before new output interrupts it. Default 3000. Set 0 to render immediately. Claude Code caps the hold at 600000 (10 minutes). Your first keystroke ends the hold early. Requires Claude Code v2.1.217 or later |
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR | Return to the original working directory after each Bash or PowerShell command in the main session |
CLAUDE_BYTE_STREAM_IDLE_TIMEOUT_MS | Timeout in milliseconds for the byte-level streaming idle watchdog; when set, it takes precedence over CLAUDE_STREAM_IDLE_TIMEOUT_MS for that watchdog and leaves the event-level watchdog unchanged. Claude Code clamps this variable to between 10 seconds and 30 minutes. Requires Claude Code v2.1.210 or later |
CLAUDE_CLIENT_PRESENCE_FILE | Path to a file that an external tool, such as a screen-lock listener, creates when you unlock your screen and deletes when you lock it. While the file exists, Claude Code skips Remote Control mobile push notifications, so you stop getting pushes while you are actively using the computer. When the file is absent or unreadable, notifications are sent as normal. Claude Code checks the file once per push-triggering event rather than polling it. Requires Claude Code v2.1.181 or later |
CLAUDE_CODE_ACCESSIBILITY | Set to 1 to keep the native terminal cursor visible and disable the inverted-text cursor indicator. Allows screen magnifiers like macOS Zoom to track cursor position |
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD | Set to 1 to load memory files from directories specified with --add-dir. Loads CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md, and CLAUDE.local.md. By default, additional directories do not load memory files |
CLAUDE_CODE_ALT_SCREEN_FULL_REPAINT | Set to 1 to repaint the entire screen on every frame in fullscreen rendering instead of sending incremental updates. Use this if fullscreen mode shows stale or misplaced text fragments. Claude Code enables this automatically for background sessions and agent view on Windows |
CLAUDE_CODE_ALWAYS_ENABLE_EFFORT | Set to 1 to send the effort parameter with every request, even when Claude Code does not recognize the model ID as effort-capable. Use this when routing through an LLM gateway or third-party provider that serves models under custom identifiers. Models that reject the effort parameter at the API, including Claude 3 models, Sonnet 4.0 and 4.5, Opus 4.0 and 4.1, and Haiku 4.5, are still excluded so requests do not fail |
CLAUDE_CODE_API_KEY_HELPER_TTL_MS | Interval in milliseconds at which credentials should be refreshed (when using apiKeyHelper) |
CLAUDE_CODE_ARTIFACT_AUTO_OPEN | Set to 0 to stop Claude Code from opening the browser automatically when a new artifact is published |
CLAUDE_CODE_ARTIFACT_COMMENTS | Set to 0 to stop Claude reading and replying to comments on an artifact. Has no effect when CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC has turned artifacts off. Requires Claude Code v2.1.221 or later |
CLAUDE_CODE_ARTIFACT_COMMENTS_AUTOREACT | Set to 0 to stop Claude replying on its own to comments sent to it. Requires Claude Code v2.1.228 or later |
CLAUDE_CODE_ATTRIBUTION_HEADER | Set to 0 to omit the attribution block, which carries the client version and a prompt fingerprint, from the start of the system prompt. Caching on a direct connection to the Anthropic API is unaffected either way. In some direct-connection setups, Claude Code keeps the block on auto mode classifier requests even when you set 0. In System prompt attribution block, check which connections and credentials this covers. Before v2.1.181 the block included a per-request token on custom base URLs and Microsoft Foundry connections, so on those versions set it to 0 when your LLM gateway caches on the request body or forwards requests to a third-party provider, or when you connect to Microsoft Foundry directly |
CLAUDE_CODE_AUTO_BACKGROUND_WORKER_CHECKIN_SECONDS | When CLAUDE_AUTO_BACKGROUND_TASKS is enabled, seconds between reminders to Claude to check on background subagents that are still running. Accepts a plain integer from 1 to 86400 only; any other value or spelling reads as unset. When unset, there are no check-in reminders. Requires Claude Code v2.1.248 or later |
CLAUDE_CODE_AUTO_COMPACT_WINDOW | Set the auto-compact window in tokens, from 100000 to 1000000. Accepts a plain integer such as 500000 only: a value like 500k reads as 500 and clamps to the 100K minimum. The effective window is also capped at the model’s context window. Takes precedence over the /autocompact command, the --autocompact flag, and the autoCompactWindow setting. The status line’s used_percentage always measures against the model’s full context window, so once this variable is set, that percentage no longer indicates when compaction will run |
CLAUDE_CODE_AUTO_CONNECT_IDE | Override automatic IDE connection. By default, Claude Code connects automatically when launched inside a supported IDE’s integrated terminal. Set to false to prevent this. Set to true to force a connection attempt when auto-detection fails, such as when tmux obscures the parent terminal. Takes precedence over the autoConnectIde global config setting |
CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS | Time in milliseconds Claude Code waits for the AWS default credential provider chain to produce credentials before the request fails with AWS default-chain credential resolve timed out (default: 60000). Raise it when a step in your chain legitimately needs longer, such as a browser-based SSO sign-in with MFA through a wrapper like aws-vault. Applies wherever Claude Code signs with the default chain: Amazon Bedrock, Claude Platform on AWS, and the Mantle endpoint. Requires Claude Code v2.1.207 or later |
CLAUDE_CODE_BRIDGE_SESSION_ID | Set automatically in Bash tool and hook command subprocesses while the session has an active Remote Control connection, and removed when the connection ends. The value is the session’s ID in session_ form, the same identifier that appears in the session’s claude.ai/code URL, so a script can link back to the session that ran it. Requires Claude Code v2.1.199 or later. In cloud sessions, read CLAUDE_CODE_REMOTE_SESSION_ID instead |
CLAUDE_CODE_BS_AS_CTRL_BACKSPACE | Set to 0 to make Claude Code read the 0x08 byte, also written ^H, as plain Backspace, or 1 to read it as Ctrl+Backspace. Either value replaces the platform default. By default, Claude Code reads it as Ctrl+Backspace on Windows, except when TERM_PROGRAM is mintty or TERM is cygwin, and as plain Backspace on macOS and Linux. Set 0 in a Windows terminal where Backspace deletes a whole word |
CLAUDE_CODE_CERT_STORE | Comma-separated list of CA certificate sources for TLS connections. bundled is the Mozilla CA set shipped with Claude Code. system is the operating system trust store, read only on runtimes with tls.getCACertificates: the native binary, or Node 22.15 or later for npm installs. See CA certificate store. Default is bundled,system |
CLAUDE_CODE_CHILD_SESSION | Set to 1 in subprocesses Claude Code spawns via the Bash, PowerShell, and Monitor tools, hook commands, and status line commands. Not set for stdio MCP server subprocesses, which are long-lived and outlive the session that spawned them. Unlike CLAUDECODE, this is only set by Claude Code itself when it launches a subprocess and not by IDE extensions, so it reliably distinguishes a nested session from a top-level claude launched in an IDE-integrated terminal. A nested interactive claude TUI started this way is automatically excluded from --resume, --continue, up-arrow history, and the claude agents list. Non-interactive claude -p sessions still persist. Set CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 to override this exclusion. Requires Claude Code v2.1.172 or later |
CLAUDE_CODE_CLIENT_CERT | Path to client certificate file for mTLS authentication |
CLAUDE_CODE_CLIENT_KEY | Path to client private key file for mTLS authentication |
CLAUDE_CODE_CLIENT_KEY_PASSPHRASE | Passphrase for encrypted CLAUDE_CODE_CLIENT_KEY (optional) |
CLAUDE_CODE_CONNECT_TIMEOUT_MS | Removed in v2.1.186 and now a no-op. Previously set a separate timeout for the connect, TLS, and response-header phase of a streaming API request. Use API_TIMEOUT_MS for the per-request timeout. For the response-header phase of a streaming request, see CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS |
CLAUDE_CODE_DEBUG_LOGS_DIR | Override the debug log file path. Despite the name, this is a file path, not a directory. Requires debug mode to be enabled separately via --debug, /debug, or the DEBUG environment variable: setting this variable alone does not enable logging. The --debug-file flag does both at once. Defaults to ~/.claude/debug/<session-id>.txt |
CLAUDE_CODE_DEBUG_LOG_LEVEL | Minimum log level written to the debug log file. Values: verbose, debug (default), info, warn, error. Set to verbose to include high-volume diagnostics like full status line command output, or raise to error to reduce noise |
CLAUDE_CODE_DISABLE_1M_CONTEXT | Set to 1 to disable 1M context window support. When set, 1M model variants are unavailable in the model picker, and Claude Code holds sessions on models with a native 1M window, such as Sonnet 5 and the Fable models, to a 200K window; see Extended context for how the hold is enforced. Useful for enterprise environments with compliance requirements. For its role in correcting the window for an unrecognized [1m] model ID, see Correct the window for a gateway or custom model ID |
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING | Set to 1 to disable adaptive reasoning on Opus 4.6 and Sonnet 4.6 and fall back to the fixed thinking budget controlled by MAX_THINKING_TOKENS. Has no effect on Fable models, Sonnet 5, or Opus 4.7 and later, which always use adaptive reasoning |
CLAUDE_CODE_DISABLE_ADMIN_ENV_UNION | Set to 1 to stop Claude Code from merging managed settings env blocks per key across admin sources, so only the highest-priority source’s whole env block applies, as before v2.1.223. Set it in the environment that launches Claude Code, since Claude Code ignores a copy delivered through a settings env block. Requires Claude Code v2.1.223 or later |
CLAUDE_CODE_DISABLE_ADVISOR_TOOL | Set to 1 to disable the advisor tool. The /advisor command becomes unavailable, any configured advisorModel is ignored, and the --advisor flag is accepted but has no effect, so existing scripts that pass it continue to work without errors |
CLAUDE_CODE_DISABLE_AGENT_VIEW | Set to 1 to turn off background agents and agent view: claude agents, --bg, /background, and the on-demand supervisor. Equivalent to the disableAgentView setting |
CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN | Set to 1 to disable fullscreen rendering and use the classic main-screen renderer. The conversation stays in your terminal’s native scrollback so Cmd+f and tmux copy mode work as usual. Takes precedence over CLAUDE_CODE_NO_FLICKER and the tui setting. You can also switch with /tui default. Does not apply to background sessions opened from agent view, which always use fullscreen rendering |
CLAUDE_CODE_DISABLE_ARTIFACT | Set to 1 to turn off the Artifact tool, which publishes session output as a private web page on claude.ai. Once you set it, no settings file turns the tool back on. To turn the tool off from a settings file instead, set enableArtifact to false; the deprecated disableArtifact key also turns it off |
CLAUDE_CODE_DISABLE_ATTACHMENTS | Set to 1 to disable attachment processing. File mentions with @ syntax are sent as plain text instead of being expanded into file content |
CLAUDE_CODE_DISABLE_AUTO_MEMORY | Set to 1 to disable auto memory. Set to 0 to force auto memory on even when --bare mode or autoMemoryEnabled: false would otherwise disable it. When disabled, Claude does not create or load auto memory files |
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS | Set to 1 to disable all background task functionality, including the run_in_background parameter on Bash and subagent tools, auto-backgrounding, and the Ctrl+B shortcut |
CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_DEFAULT | Set to 1 to stop Claude Code from treating an Amazon Bedrock streaming response with a missing or empty Content-Type header as Amazon Bedrock’s binary event stream. By default, Claude Code assumes a gateway dropped the header from an otherwise unmodified response, so it decodes the body and streaming keeps working. Set this only for a gateway that also re-emits the stream as server-sent events; Claude Code then reads the header-less body as server-sent events instead. Requires Claude Code v2.1.239 or later |
CLAUDE_CODE_DISABLE_BEDROCK_CONTENT_TYPE_GUARD | Set to 1 to skip the check that an Amazon Bedrock streaming response carries the application/vnd.amazon.eventstream content-type. Without this variable, when a response carries a different content-type, Claude Code fails the request with an error naming that type, which means a gateway or proxy is transforming the response. Configure the gateway to forward the Content-Type header and body unmodified rather than setting this variable. Requires Claude Code v2.1.208 or later |
CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFF | Set to 1 to stop a background session’s running background shell commands, dynamic workflows, and, as of v2.1.198, background subagents when the supervisor stops, restarts, or updates that session’s process, instead of handing them to the session’s next process. Affects only that handoff: backgrounding a session with ← or |