Claude Code provides a series of environment variables to fine-tune its behavior. This reference handbook organizes all available environment variables for your configuration needs.

Debugging and Diagnostics

Core Debug Variables

VariableDefaultDescription
CLAUDE_CODE_DEBUGunsetEnable debug mode, output detailed logs
CLAUDE_CODE_DEBUG_TOOLSunsetEnable tool call debugging
CLAUDE_CODE_DEBUG_HTTPunsetEnable HTTP request debugging
CLAUDE_CODE_DUMP_AUTO_MODEunsetExport YOLO classifier input/output for debugging permission decisions
DEBUGunsetGeneral debug switch, affects dependency libraries
VariableDefaultDescription
CLAUDE_CODE_LOG_LEVELinfoLog level: debug, info, warn, error
CLAUDE_CODE_LOG_FILEunsetLog file path, default outputs to console
CLAUDE_CODE_LOG_TIMESTAMPStrueWhether to include timestamps in logs

API and Models

API Configuration

VariableDefaultDescription
ANTHROPIC_API_KEYunsetAnthropic API key
CLAUDE_CODE_API_KEYunsetDedicated API key (higher priority than ANTHROPIC_API_KEY)
CLAUDE_CODE_API_BASE_URLhttps://api.anthropic.comAPI base URL
CLAUDE_CODE_MODELclaude-sonnet-4-6Default model to use
CLAUDE_CODE_MAX_TOKENS8192Maximum output tokens

Model-Specific Configuration

VariableDefaultDescription
CLAUDE_CODE_EFFORT_LEVELunsetReasoning effort level: low, medium, high, max
CLAUDE_CODE_FAST_MODEunsetWhether to enable Fast Mode
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKINGfalseWhether to disable adaptive thinking
MAX_THINKING_TOKENSunsetMaximum tokens for thinking mode

Third-Party Providers

VariableDefaultDescription
AWS_ACCESS_KEY_IDunsetAWS Bedrock access key
AWS_SECRET_ACCESS_KEYunsetAWS Bedrock secret key
AWS_REGIONunsetAWS region
GOOGLE_APPLICATION_CREDENTIALSunsetGoogle Vertex AI credentials path
GOOGLE_CLOUD_PROJECTunsetGoogle Cloud project ID

Context and Cache

Cache Control

VariableDefaultDescription
CLAUDE_CODE_CACHE_ENABLEDtrueWhether to enable prompt caching
CLAUDE_CODE_CACHE_TTL3600Cache TTL (seconds), default 1 hour
CLAUDE_CODE_DISABLE_PROMPT_CACHEfalseCompletely disable prompt caching
CLAUDE_CODE_DISABLE_CACHE_EDITINGfalseDisable cache editing feature

Compaction Configuration

VariableDefaultDescription
CLAUDE_CODE_DISABLE_AUTO_COMPACTfalseDisable auto compaction
CLAUDE_CODE_COMPACT_THRESHOLD150000Auto compaction trigger threshold (tokens)
CLAUDE_CODE_COMPACT_MIN_MESSAGES10Minimum message count to trigger compaction

Token Budget

VariableDefaultDescription
CLAUDE_CODE_MAX_CONTEXT_TOKENS200000Maximum context tokens
CLAUDE_CODE_OUTPUT_TOKEN_RESERVE8192Output token reserve
CLAUDE_CODE_TOKEN_BUFFER10000Token buffer

Permissions and Security

Permission Modes

VariableDefaultDescription
CLAUDE_CODE_PERMISSION_MODEdefaultPermission mode: default, acceptEdits, plan, auto, dontAsk
CLAUDE_CODE_DISABLE_PERMISSIONSfalseDisable permission checks (dangerous)
CLAUDE_CODE_YOLO_ENABLEDtrueWhether to enable YOLO classifier
CLAUDE_CODE_YOLO_DISABLEDfalseCompletely disable YOLO classifier

Security Settings

VariableDefaultDescription
CLAUDE_CODE_DISABLE_BASH_SANDBOXfalseDisable Bash sandbox (dangerous)
CLAUDE_CODE_ALLOW_DANGEROUS_COMMANDSfalseAllow dangerous commands (like rm -rf /)
CLAUDE_CODE_DISABLE_GIT_SAFETYfalseDisable Git safety protocol (dangerous)

Memory System

Memory Control

VariableDefaultDescription
CLAUDE_CODE_DISABLE_AUTO_MEMORYfalseDisable automatic memory extraction
CLAUDE_CODE_DISABLE_AUTO_DREAMfalseDisable overnight memory consolidation
CLAUDE_COWORK_MEMORY_PATH_OVERRIDEunsetOverride memory directory path
CLAUDE_CODE_MEMORY_LOG_LEVELinfoMemory system log level

Session Memory

VariableDefaultDescription
CLAUDE_CODE_SESSION_MEMORY_ENABLEDtrueWhether to enable Session Memory
CLAUDE_CODE_SESSION_MEMORY_THRESHOLD10000Session Memory trigger threshold (tokens)

Skills System

VariableDefaultDescription
CLAUDE_CODE_SKILLS_ENABLEDtrueWhether to enable skills system
CLAUDE_CODE_SKILL_PATHunsetCustom skills search path
CLAUDE_CODE_DISABLE_BUILTIN_SKILLSfalseDisable built-in skills
CLAUDE_CODE_SKILL_BUDGET_PERCENT1Percentage of context for skills list

Agent System

VariableDefaultDescription
CLAUDE_CODE_DISABLE_SUBAGENTSfalseDisable sub-agent functionality
CLAUDE_CODE_MAX_CONCURRENT_AGENTS5Maximum concurrent agents
CLAUDE_CODE_AGENT_TIMEOUT300Agent timeout (seconds)

Feature Flags

Experimental Features

VariableDefaultDescription
CLAUDE_CODE_COORDINATOR_MODEfalseEnable coordinator mode
CLAUDE_CODE_EXPERIMENTAL_SKILLSfalseEnable experimental skills
CLAUDE_CODE_VOICE_ENABLEDfalseEnable voice input
CLAUDE_CODE_ALWAYS_THINKINGfalseAlways enable thinking mode

KAIROS Mode

VariableDefaultDescription
CLAUDE_CODE_KAIROS_ENABLEDfalseEnable KAIROS background mode
CLAUDE_CODE_KAIROS_TICK_INTERVAL60000Tick interval (milliseconds)
CLAUDE_CODE_KAIROS_CHANNELSunsetEnable channels list

Session Management

VariableDefaultDescription
CLAUDE_CODE_SESSION_IDauto-generatedCustom session ID
CLAUDE_CODE_RESUME_SESSIONfalseResume last session
CLAUDE_CODE_DISABLE_TRANSCRIPTfalseDisable session recording
CLAUDE_CODE_TRANSCRIPT_PATHunsetCustom session recording path

Git and Version Control

VariableDefaultDescription
CLAUDE_CODE_GIT_ENABLEDtrueEnable Git integration
CLAUDE_CODE_AUTO_COMMITfalseAuto commit changes
CLAUDE_CODE_COMMIT_MESSAGE_STYLEconventionalCommit message style
CLAUDE_CODE_DISABLE_PRE_COMMIT_HOOKSfalseDisable pre-commit hooks

Network and Proxy

VariableDefaultDescription
HTTP_PROXYunsetHTTP proxy address
HTTPS_PROXYunsetHTTPS proxy address
NO_PROXYunsetProxy bypass list
CLAUDE_CODE_TIMEOUT120Request timeout (seconds)
CLAUDE_CODE_RETRY_ATTEMPTS3Retry attempts

User Type

VariableDefaultDescription
USER_TYPEexternalUser type: ant (internal), external (external)
CLAUDE_CODE_ORG_IDunsetOrganization ID

Quick Configuration Examples

Debug Mode

# Enable full debugging
export CLAUDE_CODE_DEBUG=1
export CLAUDE_CODE_LOG_LEVEL=debug
export CLAUDE_CODE_DUMP_AUTO_MODE=1

claude

High Performance Mode

# Maximize performance
export CLAUDE_CODE_EFFORT_LEVEL=low
export CLAUDE_CODE_FAST_MODE=1
export CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=true

claude

Safe Mode

# Most conservative security settings
export CLAUDE_CODE_PERMISSION_MODE=default
export CLAUDE_CODE_YOLO_DISABLED=1
export CLAUDE_CODE_DISABLE_BASH_SANDBOX=false

claude

Development Debug Mode

# Use during development
export CLAUDE_CODE_DEBUG=1
export CLAUDE_CODE_DISABLE_AUTO_COMPACT=true  # Convenient to view full context
export CLAUDE_CODE_DUMP_AUTO_MODE=1          # Debug permission decisions
export CLAUDE_CODE_DISABLE_AUTO_MEMORY=true   # Avoid memory interference

claude

CI/CD Mode

# For automation scripts
export CLAUDE_CODE_PERMISSION_MODE=auto
export CLAUDE_CODE_DISABLE_AUTO_MEMORY=true
export CLAUDE_CODE_NON_INTERACTIVE=1
export CLAUDE_CODE_LOG_LEVEL=error

claude --command "..."

Configuration Priority

Environment variables > Local settings > User settings > Defaults

Environment Variables (highest priority)
.claude/settings.local.json (project-level)
~/.claude/settings.json (user-level)
Built-in defaults (lowest priority)

Important Notes

Sensitive Information

The following variables contain sensitive information, avoid committing to version control:

  • ANTHROPIC_API_KEY
  • AWS_SECRET_ACCESS_KEY
  • GOOGLE_APPLICATION_CREDENTIALS

Recommendations:

  • Use .env file and exclude in .gitignore
  • Or use system’s environment variable management tools

Dangerous Settings

The following settings bypass security mechanisms, only use when fully understanding the risks:

  • CLAUDE_CODE_DISABLE_PERMISSIONS=true
  • CLAUDE_CODE_ALLOW_DANGEROUS_COMMANDS=true
  • CLAUDE_CODE_DISABLE_GIT_SAFETY=true

Performance Tradeoffs

Some settings are tradeoffs between performance and quality:

  • EFFORT_LEVEL=low: Faster but shallower
  • FAST_MODE=1: Uses stronger models but higher cost
  • DISABLE_AUTO_COMPACT=true: Full context but reaches limits faster

Troubleshooting

Problem: Frequent Permission Prompts

# Check current permission mode
export CLAUDE_CODE_PERMISSION_MODE=auto

# Or check YOLO classifier logs
export CLAUDE_CODE_DUMP_AUTO_MODE=1

Problem: Cache Not Working

# Check cache status
export CLAUDE_CODE_DEBUG=1

# Confirm cache not disabled
unset CLAUDE_CODE_DISABLE_PROMPT_CACHE

Problem: Memory Not Working

# Check memory directory
ls ~/.claude/projects/$(basename $(git rev-parse --show-toplevel))/memory/

# Enable memory debugging
export CLAUDE_CODE_MEMORY_LOG_LEVEL=debug

This environment variables reference covers Claude Code’s main configuration options. Most users don’t need to modify these settings, but in specific scenarios (debugging, CI/CD, performance tuning), these variables give you better control over Claude Code’s behavior.