Skip to main content
Claude Code uses JSON configuration files for settings and API key approvals. Configuration can be at the system level (global) or project level (local).

Configuration Files

System-Level Configuration

Settings File: ~/.claude/settings.json
API Key Approvals: ~/.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
Local Settings (Gitignored): ./.claude/settings.local.json
Use settings.local.json to keep your personal API key out of version control while sharing base configuration with your team.

Environment Variables

The CLI sets these environment variables in your shell configuration:
These are added to:
  • ~/.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 shell
2

Project-Level Local Settings

./.claude/settings.local.json in current directory
3

Project-Level Settings

./.claude/settings.json in current directory
4

System-Level Settings

~/.claude/settings.json in home directory

Statusline Configuration (Optional)

Claude Code supports an enhanced statusline for better terminal UI:
The CLI will prompt you to set this up during configuration.

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):
Personal Configuration (.claude/settings.local.json - not committed):
Setup Instructions for Team (.claude/README.md):
  1. Or set environment variable:

Model Selection

Change the default model:
Or specify in environment variable:
See Models Catalog for available models.

Verification

Check Configuration Files

Test API Connection

Test Claude Code

Troubleshooting

Check file locations:
Verify JSON syntax:
Check permissions:
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
Check environment variable:
Verify in config:
Common mistake - trailing slash:
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 private

Project-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