Configuration Files
System-Level Configuration
Settings File:~/.claude/settings.json
~/.claude.json
The API key approval file stores the last 20 characters of your API key to remember your approval decision when Claude Code prompts you.
Project-Level Configuration
Settings File:./.claude/settings.json
./.claude/settings.local.json
Environment Variables
The CLI sets these environment variables in your shell configuration:~/.bashrc(bash)~/.zshrc(zsh)~/.config/fish/config.fish(fish)- PowerShell profile (Windows)
Verify Environment Variables
Configuration Priority
Claude Code loads configuration in this order (highest to lowest priority):1
Environment Variables
ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from your shell2
Project-Level Local Settings
./.claude/settings.local.json in current directory3
Project-Level Settings
./.claude/settings.json in current directory4
System-Level Settings
~/.claude/settings.json in home directoryStatusline Configuration (Optional)
Claude Code supports an enhanced statusline for better terminal UI:Manual Setup
If you prefer not to use the CLI:System-Level Manual Setup
Project-Level Manual Setup
Team Configuration
For team projects, separate shared config from personal API keys: Shared Configuration (.claude/settings.json - committed to git):
.claude/settings.local.json - not committed):
.claude/README.md):
- Or set environment variable:
Model Selection
Change the default model:Verification
Check Configuration Files
Test API Connection
Test Claude Code
Troubleshooting
Configuration not loading
Configuration not loading
Check file locations:Verify JSON syntax:Check permissions:
API key not recognized
API key not recognized
Verify environment variable:If empty, reload shell:Check API key in config:Verify API key format:
- Must start with
sk-mega- - At least 20 characters long
- No extra spaces or quotes
Wrong base URL being used
Wrong base URL being used
Check environment variable:Verify in config:Common mistake - trailing slash:
Project config not overriding system config
Project config not overriding system config
Check you’re in the right directory:Verify config priority:Check for settings.local.json:
Advanced Configuration
Multiple Profiles
Use different configurations for different use cases:Environment-Specific Configuration
Best Practices
Separate API Keys
Use
.gitignore for settings.local.json to keep API keys privateProject-Level for Teams
Use project-level config for team projects with shared settings
Environment Variables
Prefer environment variables in CI/CD environments
Regular Updates
Keep Claude Code updated for latest features and fixes
Next Steps
Codex Configuration
Configure Codex/Windsurf
OpenCode Configuration
Configure OpenCode
Examples
See practical examples
All Agents Config
Configure all CLI and GUI agents
Troubleshooting
Common issues and solutions

