Skip to main content

Claude Code Settings

Official configuration reference for Claude Code covering scope hierarchy, settings files, permissions, environment variables, and available tools. Source: https://code.claude.com/docs/en/settings.md Added: 2026-01-29


Configuration Scopes

ScopeLocationWho It AffectsShared?
ManagedSystem-level managed-settings.jsonAll users on machineYes (IT deployed)
User~/.claude/You, all projectsNo
Project.claude/ in repoAll collaboratorsYes (committed)
Local.claude/*.local.*You, this repo onlyNo (gitignored)

Precedence (highest to lowest):

  1. Managed (can't be overridden)
  2. Command line arguments
  3. Local
  4. Project
  5. User

Settings Files

  • User: ~/.claude/settings.json
  • Project (shared): .claude/settings.json
  • Project (personal): .claude/settings.local.json
  • Managed:
    • macOS: /Library/Application Support/ClaudeCode/
    • Linux/WSL: /etc/claude-code/
    • Windows: C:\Program Files\ClaudeCode\

Available Settings

KeyDescription
permissionsAllow/ask/deny rules for tool access
envEnvironment variables for every session
apiKeyHelperCustom script for auth values
modelOverride default model
hooksCommands before/after tool execution
statusLineCustom status line context
forceLoginMethodRestrict to claudeai or console
sandboxBash sandboxing behavior
attributionGit commit/PR attribution

Permission Settings

{
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)",
"Read(~/.zshrc)"
],
"deny": [
"Bash(curl *)",
"Read(./.env)",
"Read(./secrets/**)"
]
}
}

Evaluation order: Deny (highest) > Ask > Allow (lowest)

Wildcard patterns:

  • Bash or Bash(*) - all bash commands
  • Bash(npm run *) - npm run commands
  • Read(.env) - specific file
  • WebFetch(domain:example.com) - domain match

Sandbox Configuration

{
"sandbox": {
"enabled": true,
"autoAllowBashIfSandboxed": true,
"excludedCommands": ["git", "docker"],
"allowUnsandboxedCommands": false,
"network": {
"allowUnixSockets": ["~/.ssh/agent-socket"],
"allowLocalBinding": true
}
}
}

Attribution

{
"attribution": {
"commit": "Generated with AI\n\nCo-Authored-By: AI <ai@example.com>",
"pr": ""
}
}

Plugin Configuration

{
"enabledPlugins": {
"formatter@acme-tools": true
},
"extraKnownMarketplaces": {
"acme-tools": {
"source": {
"source": "github",
"repo": "acme-corp/claude-plugins"
}
}
}
}

Key Environment Variables

VariablePurpose
ANTHROPIC_API_KEYAPI key
ANTHROPIC_MODELOverride model
CLAUDE_CODE_ENABLE_TELEMETRYOpenTelemetry
CLAUDE_CODE_MAX_OUTPUT_TOKENSMax output tokens (default: 32,000)
CLAUDE_CODE_SHELLOverride shell
DISABLE_AUTOUPDATERDisable updates
DISABLE_TELEMETRYOpt out of telemetry
MAX_THINKING_TOKENSExtended thinking budget
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIRReturn to project dir after each command
MAX_MCP_OUTPUT_TOKENSMCP output limit
ENABLE_TOOL_SEARCHTool search behavior
CLAUDE_CODE_DISABLE_BACKGROUND_TASKSDisable background tasks
CLAUDE_AUTOCOMPACT_PCT_OVERRIDECompaction threshold
CLAUDE_ENV_FILEEnv setup script path

Available Tools

ToolDescription
BashExecute shell commands
ReadRead file contents
WriteCreate/overwrite files
EditTargeted file edits
WebFetchFetch URL content
WebSearchWeb searches
GrepSearch file patterns
GlobFind files by pattern
TaskRun subagent tasks
SkillExecute skills
LSPCode intelligence via language servers

Bash Tool Behavior

  • Working directory persists across commands
  • Environment variables do NOT persist between commands

Make Env Vars Persist

Option 1: Activate before starting Claude

conda activate myenv
claude

Option 2: Set CLAUDE_ENV_FILE

export CLAUDE_ENV_FILE=/path/to/env-setup.sh
claude

Option 3: SessionStart hook

{
"hooks": {
"SessionStart": [{
"matcher": "startup",
"hooks": [{
"type": "command",
"command": "echo 'conda activate myenv' >> \"$CLAUDE_ENV_FILE\""
}]
}]
}
}