Skip to main content

Sessions and Storage

These variables decide where Claude Code keeps its files and how it handles saved sessions. They also control installs and auto updates. CLAUDE_CONFIG_DIR is the most used one. It moves the whole .claude folder.

This page lists 78 variables. Use absolute paths. Set DISABLE_AUTOUPDATER to stop updates. Project and local settings cannot set CLAUDE_CONFIG_DIR. Set these in your shell.

Example​

export CLAUDE_CONFIG_DIR="$HOME/.claude-work"
claude

This session uses a separate config folder, so you can keep a work and a personal setup apart.

Variables​

The rows are in name order. See Environment Variables for what each column and badge means.

VariableStatusWhat it doesValues and defaultNotes
BUN_INSTALL
Undocumented: Only the program shows this item. It can change without notice.
Names the Bun install folder. Claude Code uses it to detect a Bun global install and pick bun or npm as the package manager for update and install-prefix commands.Text. Checked against <value>/install/global/ in the executable pathAuto-update and install detection
CLAUDE_AFTER_LAST_COMPACT
Undocumented: Only the program shows this item. It can change without notice.
Asks the session logs API for only the lines after the last compaction.On or off. A truthy value adds the query parameter after_last_compact=true to the session logs fetchRemote session log fetch. Not set from project env before trust
CLAUDE_BG_TCC_DISCLAIMED
Undocumented: Only the program shows this item. It can change without notice.
Marks that a macOS process already re-executed with disclaimed responsibility. This avoids a second re-exec.Text. Claude Code sets it to 1 before execve. The new process reads it, then deletes itMacOS background sessions. Not set from project env before trust
CLAUDE_BG_WORKSPACE_TRUSTED
Undocumented: Only the program shows this item. It can change without notice.
Tells a background session that the workspace was already trusted. Project settings env and hooks then stay on.On or off. The dispatcher sets 1. The session also checks the stored trust recordBackground sessions. Not set from project env before trust
CLAUDE_CODE_AUTOUPDATER_DISABLED_BY_HOST
Undocumented: Only the program shows this item. It can change without notice.
Tells Claude Code that the host manages updates. Plugin autoupdate then turns off when the host pin says so.On or offHost-embedded sessions
CLAUDE_CODE_BASE_REF
Undocumented: Only the program shows this item. It can change without notice.
Sets the git base ref that Claude Code uses in merge-base calls for diffs. Claude Code rejects a ref that starts with -.Text. A per-checkout ref from CLAUDE_CODE_BASE_REFS winsCloud and repo checkout sessions
CLAUDE_CODE_BASE_REFS
Undocumented: Only the program shows this item. It can change without notice.
Gives a base ref for each repo checkout. It feeds the same merge-base diff logic as CLAUDE_CODE_BASE_REF.TextCloud and repo checkout sessions
CLAUDE_CODE_CCR_SKIP_FRESH_MIGRATIONS
Undocumented: Only the program shows this item. It can change without notice.
Skips the config migrations on a fresh config. It marks them as done.On or off. Applies only when two further checks about a fresh cloud config passCloud sessions
CLAUDE_CODE_CHILD_SESSION
Documented: An official docs page names this item.
Marks a session that Claude Code started as a subprocess. Claude Code sets it.On or off. A nested interactive session skips --resume lists. CLAUDE_CODE_FORCE_SESSION_PERSISTENCE overrides thatAll sessions
CLAUDE_CODE_CONFIG_WATCH_EVENTS
Undocumented: Only the program shows this item. It can change without notice.
Gated: Works only behind a flag or a server gate. Works only behind a feature flag or server gate
Makes the config freshness watcher use file system events instead of interval polling.On or off, off by default. It takes effect only on Linux. Background sessions unset itLinux only
CLAUDE_CODE_DISABLE_ADMIN_ENV_UNION
Documented: An official docs page names this item.
Uses only the top admin source env block instead of merging env per key across admin sources.On or off. Must be in the environment at startManaged settings
CLAUDE_CODE_DISABLE_AWAITING_USER_IDLE
Undocumented: Only the program shows this item. It can change without notice.
Turns off the idle accounting that parks session activity while Claude waits for the user.On or off, off by defaultAll sessions
CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING
Documented: An official docs page names this item.
Turns off file checkpointing, so /rewind cannot restore code. Overrides fileCheckpointingEnabled.On or off. SDK sessions also need CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTINGAll sessions. Project env can set it before trust
CLAUDE_CODE_DISABLE_HOME_SETTINGS_SEED
Undocumented: Only the program shows this item. It can change without notice.
Stops the home settings seed from starting in the file sync worker. The start check reports disabled.On or off, off by default. Claude Code reads a truthy string from the child spawn environmentRemote and hosted sessions
CLAUDE_CODE_DISABLE_NESTED_CHAIN_IDLE
Undocumented: Only the program shows this item. It can change without notice.
Stops the session activity tracker from counting nested prompts that block on the user.On or off, off by defaultAll sessions
CLAUDE_CODE_DISABLE_NESTED_USER_REPAIR
Undocumented: Only the program shows this item. It can change without notice.
Turns off the repair of a user message that arrives wrapped one level deep on the input stream. The log then says repair_disabled.On or off, off by defaultSDK and stream input
CLAUDE_CODE_DISABLE_STARTUP_WORK_GATE
Undocumented: Only the program shows this item. It can change without notice.
Skips arming the startup work gate that makes queued startup tasks wait.On or off, off by defaultAll sessions
CLAUDE_CODE_DOWNLOAD_DEADLINE_MS_FOR_TESTING
Undocumented: Only the program shows this item. It can change without notice.
Overrides the total download deadline of the updater download, for tests.A number. Invalid or 0 gives the defaultNative installer and updater download
CLAUDE_CODE_EAGER_FLUSH
Undocumented: Only the program shows this item. It can change without notice.
Flushes the transcript to storage right after each persist, before the turn goes on.On or off, off by default. Also on when CLAUDE_CODE_IS_COWORK has a valueSDK and print mode with session persistence
CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING
Documented: An official docs page names this item.
Turns on file checkpointing in non-interactive mode.On or off, off by default. CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING still wins. The SDK sets it to true when its option is onSDK and --print mode
CLAUDE_CODE_EXIT_AFTER_STOP_DELAY
Documented: An official docs page names this item.
Exits the process this many ms after the query loop goes idle.A number, off by default. Whole number. A value above 0 turns it onSDK mode and scripts
CLAUDE_CODE_FORCE_SESSION_PERSISTENCE
Documented: An official docs page names this item.
Keeps transcripts and history when CLAUDE_CODE_CHILD_SESSION would mark a session as nested.On or off, off by defaultAll sessions
CLAUDE_CODE_HARBOR_KITE_PACING_OFF
Undocumented: Only the program shows this item. It can change without notice.
Gated: Works only behind a flag or a server gate. Works only behind a feature flag or server gate
Turns off the pacing of outbound messages to local uds inboxes. The code credits and debits a pacer for each send.On or off. When set, the pacing check returns false. When unset, a feature flag decidesAll sessions, cross-session messaging
CLAUDE_CODE_HOME_SEED_HOLD_TIMEOUT_MS
Undocumented: Only the program shows this item. It can change without notice.
Lowers the longest hold time of the home seed step. The value cannot raise the built-in maximum.A number of milliseconds. A whole number, with a minimum of 0. The result is the smaller of this value and a built-in capHost-seeded home or settings sync
CLAUDE_CODE_HOME_SEED_VERDICT_TIMEOUT_MS
Undocumented: Only the program shows this item. It can change without notice.
Lowers the longest wait for the verdict of the home seed step. The value cannot raise the built-in maximum.A number of milliseconds. A whole number, with a minimum of 0. The result is the smaller of this value and a built-in capHost-seeded home or settings sync
CLAUDE_CODE_HOST_SESSION_ID
Undocumented: Only the program shows this item. It can change without notice.
Records the session id that the host app gave in the session registry entry as hostSessionId.Text. Read only for host-started sessionsHost apps (desktop)
CLAUDE_CODE_HOST_WORKTREE
Undocumented: Only the program shows this item. It can change without notice.
Holds the worktree path that a host declares for the session. Claude Code checks it against the start directory and reports problems.Text. Claude Code deletes it from the env of child processesHost apps
CLAUDE_CODE_HOST_WORKTREE_FENCE
Undocumented: Only the program shows this item. It can change without notice.
Holds the fence that a host declares for the worktree. Claude Code checks it and reports a problem such as fence_too_wide.Text. Claude Code deletes it from the env of child processesHost apps
CLAUDE_CODE_HOVER_REST
Undocumented: Only the program shows this item. It can change without notice.
Gated: Works only behind a flag or a server gate. Works only behind a feature flag or server gate
Pins the storage backend and the config home at start. Claude Code then reports a later change of CLAUDE_CONFIG_DIR.On, off, or unset, off if unset. Any truthy string also triggers the pin at CLI entry. Unset falls back to a feature flagAll sessions
CLAUDE_CODE_MANAGED_SETTINGS_PATH
Undocumented: Only the program shows this item. It can change without notice.
Names the folder of managed (policy) settings in place of the machine default. This build ignores it. We set it to a folder with managed-settings.json. The debug log still read the machine default folder.Text. Claude Code also sets it to a config dir in the env it builds for isolated runsAll sessions, managed settings
CLAUDE_CODE_MESSAGING_SOCKET
Documented: An official docs page names this item.
Gives the path of the session inbox socket to hooks and Bash commands.Set by Claude Code when it binds the socketSessions with cross-session messaging
CLAUDE_CODE_MESSAGING_TOKEN
Documented: An official docs page names this item.
Gives a per-session token that a script can send to the inbox socket to prove it belongs to the session.Text (a secret). Set by Claude Code beside the socket path. Claude Code deletes it when the socket closesSessions with cross-session messaging
CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE
Documented: An official docs page names this item.
Lets Claude Code run the package manager upgrade command in the background. Matches the docs for Homebrew and WinGet.On or off. The upgrade runs with a 300000 ms timeout and logs pm_homebrew or pm_winget telemetryHomebrew and WinGet installs
CLAUDE_CODE_PROJECT_DIR_NAME
Documented: An official docs page names this item.
Sets the projects/ subdir name for transcripts and memory. Needs CLAUDE_CONFIG_DIR.Text. Claude Code refuses Windows reserved namesAll sessions
CLAUDE_CODE_RELAUNCH_HOME_TRUST
Undocumented: Only the program shows this item. It can change without notice.
Carries a pid:starttime token across a relaunch. It proves that the home dir trust came from the parent process.Text. Claude Code sets it on relaunchRelaunched sessions
CLAUDE_CODE_RELAUNCH_PROACTIVITY_BASELINE
Undocumented: Only the program shows this item. It can change without notice.
Carries the proactivity baseline permission mode across a relaunch. Claude Code drops bypassPermissions when it is not allowed.Claude Code sets it on relaunch. It reads it once and deletes it from the envRelaunched sessions
CLAUDE_CODE_RELAUNCH_PROACTIVITY_DECIDED
Undocumented: Only the program shows this item. It can change without notice.
Carries across a relaunch whether the proactivity choice was already made.Claude Code sets it on relaunch. It reads it once and deletes itRelaunched sessions
CLAUDE_CODE_RELAUNCH_PROACTIVITY_EVER_ON
Undocumented: Only the program shows this item. It can change without notice.
Carries across a relaunch whether proactivity was ever on.Claude Code sets it on relaunch. It reads it once and deletes it from the envRelaunched sessions
CLAUDE_CODE_RELAUNCH_PROACTIVITY_LEVEL
Undocumented: Only the program shows this item. It can change without notice.
Carries the proactivity level across a relaunch. An invalid level clears the related relaunch vars.Claude Code sets it on relaunch. It reads it once and deletes it from the envRelaunched sessions
CLAUDE_CODE_RESTRICT_PERSONAL_CONFIG
Undocumented: Only the program shows this item. It can change without notice.
Restricts use of personal Claude Code files, per a bundle message. The check also reads a settings-level source.On or off. Part of the env list that background sessions pass onAll sessions
CLAUDE_CODE_RESUME_FROM_SESSION
Undocumented: Only the program shows this item. It can change without notice.
Names a source session to load at start with the sessions API. It applies when a URL or SDK URL start has no messages.Text. Claude Code clears it for child worker processesRemote and SDK starts
CLAUDE_CODE_RESUME_INTERRUPTED_TURN
Documented: An official docs page names this item.
Resumes a turn that ended in the middle.On or off. Claude Code sets it to 1 when it restarts a worker or background session a second timeSDK and background sessions
CLAUDE_CODE_RESUME_INTERRUPTED_TURN_MAX_AGE_MS
Documented: An official docs page names this item.
Bounds the age of the last message for auto resume of a turn.A number of milliseconds. 0 or unset gives no bound. Negative or non-numeric gives 3600000 msSDK and background sessions
CLAUDE_CODE_RESUME_PROMPT
Documented: An official docs page names this item.
Overrides the continuation text that Claude Code sends to the model when an interrupted turn resumes instead of resending its prompt.Text, Continue from where you left off. by default. Empty string uses the default. The background supervisor sets it on respawn after a first attemptResume, background sessions, -p. Not set from project env before trust
CLAUDE_CODE_RESUME_REASON
Undocumented: Only the program shows this item. It can change without notice.
Names why a host resumed an interrupted turn. The first reply frames of the resumed turn carry the value.Text. Other values fall back to interrupted_turnHosts and SDK output. Docs of the SDK frame list examples such as host_draining
CLAUDE_CODE_RESUME_SESSIONSTART_HOOKS_WAIT_MS
Undocumented: Only the program shows this item. It can change without notice.
On resume, waits up to this many ms for SessionStart hooks, then continues without them. A Probes run saw no effect.A number of milliseconds. Integer 1 to 2147483647, unset by default. When unset, resume does not wait for these hooksResume of a session that has messages
CLAUDE_CODE_RESUME_SOURCE_ALIVE
Undocumented: Only the program shows this item. It can change without notice.
Tells a resumed or forked session that its source session is still alive. It carries ids and a boundary time used to skip rows already seen.Text. Fields seen are sessionId, parentSessionId, and boundaryAtResume and fork. A host sets it. Not set from project env before trust
CLAUDE_CODE_RESUME_THRESHOLD_MINUTES
Undocumented: Only the program shows this item. It can change without notice.
Gated: Works only behind a flag or a server gate. Works only behind a feature flag or server gate
Sets the idle age in minutes after which a resumed session receives the return prompt. Default is 70.A number, 70 by default. Integer, default 70. Works only when a feature flag or a feature flag is onInteractive resume. Gated by a feature flag and a feature flag
CLAUDE_CODE_RESUME_TOKEN_THRESHOLD
Undocumented: Only the program shows this item. It can change without notice.
Gated: Works only behind a flag or a server gate. Works only behind a feature flag or server gate
Sets the estimated token size above which a resumed session receives the return prompt. Default is 100000.A number, 100000 by default. Integer, default 100000. Works only when a feature flag or a feature flag is onInteractive resume. Gated by a feature flag and a feature flag
CLAUDE_CODE_RESUME_TOLERATES_CONTEXT_APPENDS
Undocumented: Only the program shows this item. It can change without notice.
On resume, does not treat trailing context-only user rows from the host as a new prompt. This keeps interrupted-turn detection correct.On or off. Claude Code also passes it to the parked-permission logic as toleratesContextAppendsResume and SDK or remote hosts
CLAUDE_CODE_RESUME_TOLERATES_CONTEXT_SEEDS
Undocumented: Only the program shows this item. It can change without notice.
On resume, lets context seed rows and queued task notifications pass in interrupted-turn detection. Then the log reads as no turn rows.On or offResume and SDK or remote hosts
CLAUDE_CODE_SESSION_ID
Documented: An official docs page names this item.
Holds the current session ID for Bash, hook, and stdio MCP subprocesses. Session sync also reads it.Text. Claude Code sets it for subprocesses. Claude Code deletes it from some inherited envs so a child does not reuse it. For stdio MCP servers the ID stays as it was at spawnBash, PowerShell, hooks, MCP stdio. Claude Code sets it
CLAUDE_CODE_SESSION_KIND
Undocumented: Only the program shows this item. It can change without notice.
Names the kind of session. The value bg marks a background session, which changes cwd handling and restart advice.Text. The code seen tests only the value bgBackground sessions. The supervisor sets it
CLAUDE_CODE_SESSION_NAME
Undocumented: Only the program shows this item. It can change without notice.
Sets the session name in the concurrent-session record. A user-set name has source user.Text. The code trims it. An empty result means no nameConcurrent-session registry, background sessions
CLAUDE_CODE_SESSION_START_ANNOUNCEMENTS_BEFORE_PROMPT
Undocumented: Only the program shows this item. It can change without notice.
Changes the order of session start announcements relative to the first prompt. When set, they come before it.On or off. The exact order effect was not read furtherAll sessions
CLAUDE_CODE_SKIP_PROMPT_HISTORY
Documented: An official docs page names this item.
Skips writing prompt history and session transcripts to disk. Such sessions do not show in resume or up-arrow history.On or off. Persistence reports the reason skip_prompt_history. It also marks a nested ambient sessionAll sessions
CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING
Undocumented: Only the program shows this item. It can change without notice.
Overrides the no-data stall timeout of the update download. Meant for tests.A number. A zero or invalid value falls back to 120000 msInstaller and updater downloads
CLAUDE_CODE_STARTUP_FAILURE_RESULTS
Documented: An official docs page names this item.
Makes a stream-json run write a result message with a startup_failure_reason for startup failures that end with stderr alone.On or offPrint mode with --output-format stream-json
CLAUDE_CODE_TMPDIR
Documented: An official docs page names this item.
Overrides the temp directory for internal temp files. Claude Code also passes it to child shells and uses it as TMPDIR in the sandbox.Text. Falls back to /tmp. The sandbox also reads undocumented CLAUDE_TMPDIR and uses /tmp/claude lastAll sessions
CLAUDE_CODE_TRANSCRIPT_LOCAL_GC
Documented: An official docs page names this item.
Differs: The official docs and the program disagree. The row says how. The official docs and the program disagree. The row says how.
Trims the transcript before each compaction once the file passes 5 MB. The docs match this. The docs omit that 0 also blocks a flag-driven path.On, off, or unset. For the remote path it overrides a feature flag. The local path needs non-interactive and not CLAUDE_CODE_REMOTE-p and SDK sessions
CLAUDE_CODE_TRANSCRIPT_SLIM_TOOL_RESULTS
Undocumented: Only the program shows this item. It can change without notice.
Picks slim over counted mode for tool results in the transcript of SDK sessions that use an SDK URL.On or off. Read at startup in non-interactive sessions with an SDK URLSDK URL sessions
CLAUDE_CONFIG_DIR
Documented: An official docs page names this item.
Sets the config directory in place of ~/.claude. It also changes the name of the secure storage entry with a hash of the path.TextAll sessions
CLAUDE_IMPORT_CONVERSATIONS
Undocumented: Only the program shows this item. It can change without notice.
Enables the import-conversations command. Without it the command says it is not enabled.On or off. The command also needs --cwdCLI import command
CLAUDE_JOB_DIR
Documented: An official docs page names this item.
Holds the job directory of a background session. Claude Code writes exit-cause and exit-detail files there.A path. Claude Code sets itBackground sessions
CLAUDE_RELAUNCH_SESSION_ADD_DIRS
Undocumented: Only the program shows this item. It can change without notice.
Carries the session --add-dir paths over a relaunch of Claude Code.--
CLAUDE_TMPDIR
Undocumented: Only the program shows this item. It can change without notice.
Sets the temp directory for the Bash sandbox, after CLAUDE_CODE_TMPDIR.--
DISABLE_AUTOUPDATER
Documented: An official docs page names this item.
Turns off automatic background updates.On or off-
DISABLE_INSTALLATION_CHECKS
Documented: An official docs page names this item.
Turns off installation warnings.On or off-
DISABLE_UPDATES
Documented: An official docs page names this item.
Blocks every update, including claude update and claude install, with the message "Updates are disabled by your administrator".On or off. Claude Code also reports it as the reason the auto-updater is off, ahead of DISABLE_AUTOUPDATERAll sessions. Project env can set it before trust
TEMP
Documented: An official docs page names this item.
Names the temp directory. Claude Code uses it to find the temp dir when CLAUDE_CODE_TMPDIR is not set.Text. Non-empty string. On Windows, Claude Code tries TEMP, then TMPAll sessions
TERMUX_VERSION
Undocumented: Only the program shows this item. It can change without notice.
Marks the Termux app on Android. Claude Code then uses $PREFIX/tmp instead of /tmp for sockets and daemon files.Text. Non-empty string, with PREFIX set. Claude Code uses it for the daemon dir, the socks dir, and a path checkTermux on Android
TMP
Documented: An official docs page names this item.
Names the temp directory. Claude Code uses it as a fallback when CLAUDE_CODE_TMPDIR and TMPDIR are not set.Text. Non-empty string. On Windows, Claude Code tries TEMP then TMPAll sessions
TMPDIR
Documented: An official docs page names this item.
Names the temp directory. Claude Code uses it as the temp root on Linux when CLAUDE_CODE_TMPDIR is not set.Text. Non-empty string. macOS ignores it for the temp root. Claude Code also adds it to the allowed write pathsAll sessions
XDG_CACHE_HOME
Documented: An official docs page names this item.
Names the XDG cache directory. Claude Code uses it for cache paths and adds it to allowed sandbox paths.Text. Non-empty string. Default is ~/.cacheLinux
XDG_CONFIG_HOME
Documented: An official docs page names this item.
Names the XDG config directory. Claude Code uses it for the global git ignore file and the Anthropic config dir.A path. Non-empty absolute path. Default is ~/.configLinux and macOS
XDG_DATA_HOME
Documented: An official docs page names this item.
Names the XDG data directory. Claude Code uses it to find shell history and adds it to allowed sandbox paths.Text. Non-empty string. Default is ~/.local/shareLinux
XDG_RUNTIME_DIR
Undocumented: Only the program shows this item. It can change without notice.
Names the XDG runtime directory. Claude Code puts the cc-socks socket dir under it.Text, dir by default. Non-empty string. Falls back to a default dir if unset or if the path is too long for a socketLinux
XDG_STATE_HOME
Documented: An official docs page names this item.
Names the XDG state directory. Claude Code uses it for log and state paths and adds it to allowed sandbox paths.Text. Non-empty string. Default is ~/.local/stateLinux

How It Works​

Claude Code writes settings, transcripts, and caches under the config folder. Settings files copy env values as written. No shell expands them, so ~ and $HOME stay as typed. Use an absolute path in settings.json.

Source: the program (variable names found in the 2.1.312 binary) and the Environment Variables page of the official docs.