Claude Code Configuration: Settings, Environment Variables, and Defaults
The Settings File
Claude Code stores project-level and global configuration in claude_settings.json. In your home directory for global defaults, or in a project root for per-project settings. The project-level file overrides global settings.
{
"defaultModel": "sonnet-4-6",
"maxTokens": 8192,
"autoMode": false
}
Run claude --help to see the full list of configuration options and what they do.
Environment Variables
Claude Code respects standard environment variables for API configuration:
ANTHROPIC_API_KEY— your API key (if not using default credentials)CLAUDE_CODE_CONFIG_DIR— override where Claude Code looks for settingsHTTP_PROXY/HTTPS_PROXY— if you need a proxy for API calls
For team deployments, you can set these in a .env.local that Claude Code reads on startup.
Model Selection Per Project
Set the default model per project by adding claude_settings.json to your project root:
{
"defaultModel": "opus-4.7",
"autoMode": false
}
This is useful when some projects need the extra reasoning of Opus while others are fine with Sonnet. The setting persists for that project without affecting other work.
Hook Configuration
Hooks are configured in the same settings file:
{
"hooks": {
"preCommand": "./scripts/pre-command.sh",
"postCommit": "echo 'Commit complete'"
}
}
Hooks run shell scripts at specific points in Claude Code's workflow. Useful for notification systems, quality gates, and project-specific automation.
Get Started with Claude Code
Start building with Claude Code today. Free to download, powerful enough for production.