Claude Code settings
Settings control how Claude Code loads memory, permissions, hooks, MCP servers, models, and UI preferences. Good settings reduce repeated manual setup across sessions and teammates.
- Last verified
- Applies to
- Claude Code 2.1.x. CLI spellings were checked on local version 2.1.198; official docs may describe newer 2.1.x behavior.
- Verification method
- Settings scopes, local-file location, source selection, merge behavior, and permission precedence were reviewed in official docs and local help. No real settings file was modified.
- Official sources
- SettingsPermissionsChangelog
Reproducible practice
Test a project setting in isolation before sharing it
Distinguish project, local, user, and command-line settings while avoiding overwrite of existing configuration.
Prerequisites
- A unique temporary git repository.
- jq for syntax checks.
- One reversible setting with a documented key and expected scope.
Steps
Create isolated project and local layers
Never run the fixture over an existing `.claude` directory.
Step 1 SETTINGS_LAB=$(mktemp -d "${TMPDIR:-/tmp}/claude-settings.XXXXXX") printf '%s\n' "$SETTINGS_LAB" cd "$SETTINGS_LAB" && git init -q mkdir .claude printf '%s\n' '{"permissions":{"allow":["Read"]}}' > .claude/settings.json printf '%s\n' '{"permissions":{"deny":["Read(.env)"]}}' > .claude/settings.local.jsonValidate both files
Syntax is necessary but does not prove effective merge behavior.
Step 2 jq -e . .claude/settings.json >/dev/null jq -e . .claude/settings.local.json >/dev/nullSelect sources explicitly
Start an optional session with only project and local sources to exclude unrelated user settings.
Step 3 claude --setting-sources project,localExercise a denial
Request a normal file and `.env`; inspect the actual permission result without placing a secret in the fixture.
Expected result
The project allow rule and local deny rule are both attributable, `.env` remains denied, and no user setting is needed for the test.
Validation
- Use `/status` or `/config` only to inspect effective state, not to infer undocumented merge rules.
- Check both JSON files and git status separately.
- Verify local settings remain untracked before using the pattern in a real repo.
Failure handling
Setting appears ignored
Check scope, repository root, supported key, and whether print mode silently ignored invalid settings.
Layers conflict
Reduce to one key and one source pair; remember deny rules retain precedence.
Cleanup or rollback
- Exit, return to the original directory, verify SETTINGS_LAB is the printed mktemp path, and remove only it.
- In a real project, revert shared settings by reviewed commit and preserve unrelated local settings.
Boundaries and when not to use it
- Local settings may resolve to the repository root across worktrees in newer 2.1.x versions.
- Managed settings and security controls can override or supplement project choices; local tests cannot prove organization policy.
Settings layers
Claude Code merges settings from multiple scopes. Managed or org policy can override user defaults; project settings refine behavior for a repository.
User settings
Personal defaults in your Claude Code config directory apply across projects.
Read guideProject settings
Repository-level settings in `.claude/` apply to everyone working in that codebase.
Read guideManaged policy
Organization-managed settings enforce security, MCP allowlists, and deployment rules.
Read guideCommon settings to configure
Most teams configure permissions, additional directories, model defaults, diff tool behavior, and theme or output preferences early in adoption.
| Command | Description |
|---|---|
/config | Open the settings UI or set key=value pairs directly. |
/permissions | Configure allow, ask, and deny tool rules for the session. |
--settings | Load a JSON settings file for scripted or CI sessions. |
--add-dir | Grant access to extra working directories for the current run. |
/config theme=dark
/config model=sonnetEnvironment variables
Environment variables can override auth, debug logging, feature flags, and integration behavior. They are useful for CI, containers, and team-standard shells.
Debug and logging
Use debug env vars when hooks, MCP, or API calls fail intermittently.
Read guideAuth context
Launch editors and terminals from the same environment when auth depends on inherited variables.
Read guideCI scripts
Document required env vars alongside `claude setup-token` and permission flags in pipeline docs.
Read guideDebug settings that did not load
When a setting appears ignored, inspect the active session rather than assuming the file on disk was applied.
Settings in your daily workflow
Settings intersect with permissions, memory, MCP, and troubleshooting. Adjust the layer that actually controls the behavior you see.
Permissions
Use /permissions or project rules to control tool access.
Read guideMemory
Project CLAUDE.md and `.claude/` settings load at session start.
Read guideIDE diff tool
Set Diff tool via /config when using IDE integration.
Read guideCI overrides
Pass --settings and env vars in GitHub Actions jobs.
Read guideSettings checklist
Check scope
Confirm whether user, project, or managed policy settings apply to the current repository.
Read guideCommit project settings
Keep team defaults in version control so onboarding is repeatable.
Read guideUse /config for quick tweaks
Adjust theme, model, and diff tool without hunting for JSON files.
Read guideValidate with /doctor
Run diagnostics when settings files change but behavior does not.
Read guide