Skip to main content
Settings control how Claude Code behaves in your projects. They define permissions, model preferences, environment variables, hook configurations, and advanced features like status lines and context monitoring.

What Are Settings?

Settings are JSON configuration files that customize Claude Code:
  • Permissions - What Claude can and cannot do
  • Environment variables - Configuration values and secrets
  • Hooks - Event-driven automation
  • Model preferences - Which Claude model to use
  • Status lines - Real-time monitoring and feedback
  • Advanced features - Telemetry, retention, and more
Settings cascade from user → project → local, with later settings overriding earlier ones.

Settings Hierarchy

Claude Code uses three levels of settings:
Location: ~/.claude/settings.jsonScope: All projects for the current userUse for:
  • Personal preferences (editor, model)
  • Global API keys
  • User-specific automation
Committed: No (personal file)
Local settings override project settings, which override user settings. This allows personal customization without affecting the team.

Settings Structure

Settings files use JSON format:

Settings Categories

Control what Claude can execute:
  • allow-npm-commands - Enable npm/yarn operations
  • read-only-mode - Prevent all file modifications
  • deny-sensitive-files - Block access to secrets
  • allow-git-operations - Enable git commands
Configuration:
Permission Types:
  • allow - Always permit these operations
  • deny - Always block these operations
  • ask - Prompt user before executing

Real-World Examples

Example 1: Allow NPM Commands

File: Settings configuration
Behavior:
  • Claude can run npm run lint, npm run test:unit, npm run build, npm start
  • User is not prompted for permission
  • Wildcard * matches any suffix (e.g., test:unit, test:integration)

Example 2: Context Monitor Statusline

File: Settings configuration
Supporting Script: .claude/scripts/context-monitor.py The CLI automatically downloads the Python script when installing this setting. Display Output:

Example 3: Read-Only Mode

File: Settings configuration
Behavior:
  • Claude can only read files and search
  • All write operations are blocked
  • No shell commands allowed
  • Useful for code review and analysis

Installing Settings

Single Setting

You’ll be prompted to choose installation location:
  1. User settings (~/.claude/settings.json)
  2. Project settings (.claude/settings.json)
  3. Local settings (.claude/settings.local.json)
  4. Enterprise managed settings (requires admin)

Multiple Settings

Batch Installation to Specific Location

Skip prompts by using shared locations:
Settings merge with existing configuration. Conflicting settings prompt for confirmation.

Permission Patterns

Use wildcards and patterns for flexible permissions:

Wildcard Matching

Tool-Level Permissions

Path-Based Permissions

Environment Variable Best Practices

Use Variable Substitution

DON’T hardcode secrets:
DO reference environment variables:

Use .env Files

Create .env file (add to .gitignore):
Reference in settings:
Load with dotenv:

Conflict Resolution

When installing settings that conflict with existing configuration:
  1. Conflict Detection - CLI identifies conflicting values
  2. User Prompt - Shows current vs new values
  3. User Choice - Overwrite or skip
  4. Merge Strategy - Arrays merge, objects overwrite
Example conflict prompt:

Settings Merging

Array Merging

Permission arrays merge uniquely: Existing:
New:
Result:

Object Overwriting

Top-level settings overwrite: Existing:
New:
Result:

Enterprise Settings

Enterprise managed settings enforce organization-wide policies: Locations:
  • macOS: /Library/Application Support/ClaudeCode/managed-settings.json
  • Linux: /etc/claude-code/managed-settings.json
  • Windows: C:\ProgramData\ClaudeCode\managed-settings.json
Requires: Administrator privileges Use cases:
  • Security policies
  • Compliance requirements
  • Organization standards
Enterprise settings override all other settings and cannot be modified by users.

Settings Best Practices

1. Principle of Least Privilege

Only grant necessary permissions:
Not:

2. Separate Concerns

  • User settings: Personal preferences
  • Project settings: Team conventions
  • Local settings: Secrets and overrides

3. Document Settings

Add comments (in description field during installation):

4. Version Control

Commit:
  • .claude/settings.json (project settings)
Don’t commit:
  • .claude/settings.local.json (personal overrides)
  • ~/.claude/settings.json (user settings)
Add to .gitignore:

Viewing Current Settings

Check active settings:
Settings cascade: user → project → local.

Removing Settings

Manually edit settings files to remove configurations:
Remove unwanted sections or reset to {}.

Next Steps

Browse Settings

Explore 60+ available settings

Configuration

Configure Claude Code settings

Hooks

Automate with event-driven triggers

Templates

Complete project configurations