Skip to main content

Configuration Files and Settings

Claude Code uses multiple configuration files to manage settings, permissions, hooks, and integrations. Understanding these files helps you customize and optimize your Claude Code setup.

Configuration Hierarchy

Claude Code reads configuration from multiple locations with a specific precedence:
Settings cascade and merge, with later files overriding earlier ones.

Directory Structure

User Directory

Global configuration directory:

Project Directory

Project-specific configuration:

settings.json

User Settings

Location: ~/.claude/settings.json User-level settings apply globally across all projects. Example:

Project Settings

Location: .claude/settings.json Project-specific settings for team sharing (committed to git). Example:

Local Settings

Location: .claude/settings.local.json Developer-specific overrides (gitignored, never committed). Example:

settings.json Fields

Model Selection

string
Claude model to use for conversations
Options:
  • claude-sonnet-4-20250514 - Balanced performance
  • claude-opus-4-20250514 - Maximum capability
  • claude-haiku-4-20250514 - Fast responses
Example:

Permissions

object
Control what Claude Code can access and execute
Structure:
Permission Types:
  • exec - Command execution
  • read - File reading
  • write - File writing
Pattern Examples:

Hooks

object
Automation hooks triggered at specific lifecycle events
Hook Types:
  • PreToolUse - Before tool execution
  • PostToolUse - After tool execution
  • Stop - On session stop
  • Notification - For notifications
Example:

Environment Variables

object
Environment variables available to Claude Code
Example:
Warning: Never put sensitive keys in project settings (use .claude/settings.local.json instead).

Telemetry

boolean
Enable or disable usage telemetry
Default: true Example:

Cleanup Period

number
Number of days to retain conversation history
Default: 30 Options:
  • 7 - One week
  • 30 - One month (default)
  • 90 - Three months
  • 365 - One year
  • -1 - Never delete
Example:

MCP Configuration

boolean
Auto-approve all MCP servers from .mcp.json
Default: false Example:

Statusline

object
Configure statusline display
Example:

.mcp.json

MCP (Model Context Protocol) server configurations. Location: Project root (.mcp.json) Structure:

Complete Example

Server Configuration Fields

string
required
Executable command to start the server
array
Command-line arguments (optional)
object
Environment variables for the server (optional)

.claude.json

Authentication configuration. Location: ~/.claude.json Structure:
Warning: Contains sensitive authentication data. Never commit to git.

CLAUDE.md

Project context and guidelines. Location: .claude/CLAUDE.md Purpose:
  • Project overview
  • Coding standards
  • Architecture notes
  • Development guidelines
  • Important context for Claude
Example:

Gitignore Recommendations

Add to .gitignore:
Commit to git:
  • .claude/CLAUDE.md
  • .claude/settings.json
  • .claude/agents/
  • .claude/commands/
  • .mcp.json

Configuration Presets

Install pre-configured settings:

Security-Focused

Performance-Optimized

Development-Friendly

Best Practices

1. Separate Concerns

  • User settings: Personal preferences, global permissions
  • Project settings: Team standards, project permissions
  • Local settings: Developer-specific overrides, API keys

2. Security

  • Never commit API keys or secrets
  • Use environment variables for sensitive data
  • Add .claude/settings.local.json to .gitignore
  • Review permissions regularly

3. Team Collaboration

  • Commit .claude/settings.json for team consistency
  • Document required settings in README
  • Use environment variables for deployment-specific config
  • Share MCP configurations in .mcp.json

4. Performance

  • Set appropriate cleanupPeriodDays for conversation retention
  • Use Haiku model for simple tasks
  • Limit additionalDirectories to necessary paths
  • Monitor conversation history size

5. Documentation

  • Keep CLAUDE.md up to date with project changes
  • Document custom agents and commands
  • Explain hook purposes
  • Note required environment variables

Troubleshooting

Settings Not Applied

Check file locations:
Verify JSON syntax:
Check permissions:

Hooks Not Running

Verify hook configuration:
Test command manually:
Check command availability:

MCP Servers Not Working

Verify .mcp.json:
Test server manually:
Check server permissions:

Next Steps