Claude Code environment variables: the ones we could verify on this Mac
Of 200+ documented variables, the practical subset a solo dev is likely to actually touch.
A practical subset of 200+ variables
Per the official docs (code.claude.com/docs/en/env-vars, fetched 2026-07-29), Claude Code supports 200+ environment variables. This article picks the ones a solo dev or small team is likely to actually use, with live verification where possible.
Auth & endpoint
`ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_BASE_URL`, `ANTHROPIC_MODEL` — common when running your own proxy/gateway or using a direct API key.
Mode-switching flags, verified live
`--safe-mode` disables CLAUDE.md, skills, plugins, hooks and MCP servers, and sets `CLAUDE_CODE_SAFE_MODE=1`. On this Mac, a CLAUDE.md instruction was honored in normal mode but not under `--safe-mode`, and `echo $CLAUDE_CODE_SAFE_MODE` returned `1`.
$ claude -p "hello"
(CLAUDE.md instruction applied)
$ claude --safe-mode -p "hello, also echo $CLAUDE_CODE_SAFE_MODE"
$CLAUDE_CODE_SAFE_MODE = 1
(CLAUDE.md instruction NOT applied)--bare sets CLAUDE_CODE_SIMPLE
Per `claude --help`, `--bare` skips hooks/LSP/plugin sync/auto-memory/keychain reads and sets `CLAUDE_CODE_SIMPLE=1` — handy for minimal CI runs.
Bash timeouts
`BASH_DEFAULT_TIMEOUT_MS` (120000ms default), `BASH_MAX_TIMEOUT_MS` (600000ms default), `BASH_MAX_OUTPUT_LENGTH` — relevant for long builds/tests.
Detecting a subprocess
`CLAUDECODE` and `CLAUDE_CODE_CHILD_SESSION` are set to `1` in processes spawned by Claude Code — useful in your own hook scripts.