Configuration Guide
Configuration Files
Claude Code uses multiple configuration files to customize your development experience:
- Global Configuration:
~/.claude/config.json - Project Configuration:
./claude.config.jsonor./CLAUDE.md - Environment Variables: For API keys and other sensitive information
Global Configuration
Basic Settings
{
"apiKey": "your-api-key",
"model": "claude-3-5-sonnet-20241022",
"outputStyle": "concise",
"planMode": "auto",
"maxTokens": 8192
}
Configuration Options Details
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | - | Anthropic API key |
model | string | claude-3-5-sonnet-20241022 | Claude model to use |
outputStyle | string | balanced | Output style: concise, balanced, verbose |
planMode | string | manual | Plan mode: auto, manual, off |
maxTokens | number | 4096 | Maximum token count |
temperature | number | 0.3 | Creativity level (0-1) |
Project Configuration
CLAUDE.md File
Create a CLAUDE.md file in the project root to configure project-specific settings:
# Project: My Web Application
## Project Description
This is a modern web application using React + TypeScript.
## Coding Standards
- Use ESLint + Prettier
- Follow Airbnb code style
- Use functional components + Hooks
- Prefer TypeScript
## File Structure
- `src/components/` - React components
- `src/hooks/` - Custom Hooks
- `src/utils/` - Utility functions
- `src/types/` - TypeScript type definitions
## Important Notes
- All API calls need error handling
- Components must include PropTypes or TypeScript types
- New features need corresponding unit tests
claude.config.json
Or use JSON format for project configuration:
{
"project": {
"name": "My Web Application",
"type": "react-typescript",
"framework": "vite"
},
"codeStyle": {
"indentSize": 2,
"quotes": "single",
"semicolons": true,
"trailingComma": "es5"
},
"testing": {
"framework": "jest",
"coverageThreshold": 80
},
"hooks": {
"beforeCommit": ["npm test", "npm run lint"]
}
}
Environment Variables
Required Environment Variables
# Anthropic API key
export ANTHROPIC_API_KEY=your_api_key_here
# Optional: specify model
export CLAUDE_MODEL=claude-3-5-sonnet-20241022
# Optional: custom config file path
export CLAUDE_CONFIG_PATH=/path/to/config.json
.env File Support
Create a .env file in the project root:
ANTHROPIC_API_KEY=your_api_key_here
CLAUDE_OUTPUT_STYLE=concise
CLAUDE_PLAN_MODE=auto
CLAUDE_MAX_TOKENS=8192
Advanced Configuration
Custom Agents
{
"agents": {
"codeReviewer": {
"prompt": "As a code review expert, focus on code quality, performance, and security",
"model": "claude-3-5-sonnet-20241022",
"temperature": 0.1
},
"documentationWriter": {
"prompt": "Specialize in writing clear, comprehensive technical documentation",
"model": "claude-3-haiku-20240307",
"temperature": 0.5
}
}
}
Output Styles
{
"outputStyles": {
"development": {
"verbosity": "detailed",
"includeReasoning": true,
"showProgress": true
},
"production": {
"verbosity": "minimal",
"includeReasoning": false,
"showProgress": false
}
}
}
Hooks Configuration
{
"hooks": {
"beforeEdit": "npm run format",
"afterEdit": "npm run lint",
"beforeCommit": ["npm test", "npm run build"],
"onError": "echo 'Error occurred, please check logs'"
}
}
Enterprise Configuration
Bedrock Integration
{
"provider": "bedrock",
"bedrock": {
"region": "us-east-1",
"modelId": "anthropic.claude-3-sonnet-20240229-v1:0",
"credentials": {
"accessKeyId": "your-access-key",
"secretAccessKey": "your-secret-key"
}
}
}
Vertex AI Integration
{
"provider": "vertex",
"vertex": {
"projectId": "your-gcp-project",
"location": "us-central1",
"modelName": "claude-3-sonnet@20240229",
"credentials": "/path/to/service-account.json"
}
}
Troubleshooting
Configuration Validation
Validate your configuration:
claude config validate
View Current Configuration
claude config show
Reset Configuration
claude config reset
Configuration Templates
Web Development Template
{
"project": { "type": "web", "framework": "react" },
"codeStyle": { "prettier": true, "eslint": true },
"testing": { "framework": "jest", "coverage": true },
"deployment": { "platform": "vercel" }
}
Backend Development Template
{
"project": { "type": "backend", "framework": "express" },
"database": { "type": "postgresql", "orm": "prisma" },
"testing": { "framework": "mocha", "integration": true },
"deployment": { "platform": "heroku" }
}
Best Practices
- Version Control Configuration: Include
claude.config.jsonin version control - Environment Separation: Use different configurations for different environments
- Team Standardization: Team members should use the same project configuration
- Regular Updates: Update configuration as the project evolves
Continue to Core Mechanics to dive deep into how Claude Code works.