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: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
claude-sonnet-4-20250514- Balanced performanceclaude-opus-4-20250514- Maximum capabilityclaude-haiku-4-20250514- Fast responses
Permissions
object
Control what Claude Code can access and execute
exec- Command executionread- File readingwrite- File writing
Hooks
object
Automation hooks triggered at specific lifecycle events
PreToolUse- Before tool executionPostToolUse- After tool executionStop- On session stopNotification- For notifications
Environment Variables
object
Environment variables available to Claude Code
.claude/settings.local.json instead).
Telemetry
boolean
Enable or disable usage telemetry
true
Example:
Cleanup Period
number
Number of days to retain conversation history
30
Options:
7- One week30- One month (default)90- Three months365- One year-1- Never delete
MCP Configuration
boolean
Auto-approve all MCP servers from .mcp.json
false
Example:
Statusline
object
Configure statusline display
.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:
CLAUDE.md
Project context and guidelines. Location:.claude/CLAUDE.md
Purpose:
- Project overview
- Coding standards
- Architecture notes
- Development guidelines
- Important context for Claude
Gitignore Recommendations
Add to.gitignore:
.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.jsonto.gitignore - Review permissions regularly
3. Team Collaboration
- Commit
.claude/settings.jsonfor team consistency - Document required settings in README
- Use environment variables for deployment-specific config
- Share MCP configurations in
.mcp.json
4. Performance
- Set appropriate
cleanupPeriodDaysfor conversation retention - Use Haiku model for simple tasks
- Limit
additionalDirectoriesto necessary paths - Monitor conversation history size
5. Documentation
- Keep
CLAUDE.mdup to date with project changes - Document custom agents and commands
- Explain hook purposes
- Note required environment variables
Troubleshooting
Settings Not Applied
Check file locations:Hooks Not Running
Verify hook configuration:MCP Servers Not Working
Verify .mcp.json:Next Steps
- CLI Flags Reference - All CLI flags
- Environment Variables - Environment configuration
- Install Components - Component installation
- Health Check - Verify configuration