Skip to main content

Configuration

Essential configuration settings and setup options for optimizing your Claude Code experience.

API Key Setup

Claude Code requires an Anthropic API key to function. Set it up using one of these methods:

# Option 1: Environment variable (recommended)
export ANTHROPIC_API_KEY="your-api-key-here"

# Option 2: Add to your shell profile
echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.bashrc
source ~/.bashrc

Model Selection

Claude Code supports multiple models. You can specify which model to use:

Claude 4 Sonnet: Latest balanced performance and speed

export ANTHROPIC_MODEL="claude-sonnet-4-20250514"

Claude 4 Opus: Maximum capability for complex tasks

export ANTHROPIC_MODEL="claude-opus-4-20250514"

Claude 3.5 Haiku: Fastest and most cost-effective

export ANTHROPIC_MODEL="claude-3-5-haiku-20241022"
Important limitations: Claude 3.5 Haiku

While Haiku is cost-effective, it has significant limitations for Claude Code usage:

  • Reduced reasoning capabilities - Struggles with complex multi-step planning and architectural decisions
  • Limited context understanding - Less effective at analyzing large codebases and maintaining context across multiple files
  • Simplified code analysis - May miss subtle bugs, dependencies, or complex patterns that modern models catch
  • Basic refactoring only - Not suitable for sophisticated restructuring or feature implementations
  • Limited framework knowledge - Less effective with complex frameworks or novel coding patterns

Recommended use cases for Haiku:

  • Simple single-file edits
  • Basic syntax corrections
  • Quick code questions
  • Learning Claude Code basics before upgrading

For serious development work, Claude 4 Sonnet or Opus provide substantially better results and are worth the additional cost.

Alternative Method: You can also specify the model directly when starting Claude Code:

claude --model claude-sonnet-4-20250514
claude --model claude-opus-4-20250514
claude --model claude-3-5-haiku-20241022

MCP Configuration

Model Context Protocol (MCP) allows Claude Code to connect to external tools and services. Configure MCP servers to extend Claude's capabilities:

MCP Server Setup

MCP configuration can be stored in multiple locations:

  • Project-specific: .claude/settings.local.json (in your project directory)
  • User-specific local: ~/.claude/settings.local.json
  • User-specific global: ~/.claude/settings.json
  • Main Claude.json: ~/.claude.json
  • Dedicated MCP file: ~/.claude/mcp_servers.json

Example MCP configuration:

// Example: ~/.claude.json (recommended for reliability)
{
"projects": {
"/path/to/your/project": {
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/username/Desktop", "/path/to/allowed/dir"]
},
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
},
"fetch": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-fetch"]
}
}
}
},
...
}

Note: If following this example ensure you update the right projects configuration.

Allowed Tools

Allowed Tools Setup

Allowed tools configuration can be stored in multiple locations:

  • Project-specific: .claude/settings.local.json (in your project directory)
  • User-specific local: ~/.claude/settings.local.json
  • User-specific global: ~/.claude/settings.json
  • Main Claude.json: ~/.claude.json

Example Allowed Tools configuration:

// Example: ~/.claude.json (recommended for reliability)
{
"projects": {
"/path/to/your/project": {
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/username/Desktop", "/path/to/allowed/dir"]
}
},
"allowedTools": [
"Task",
"Bash",
"Glob",
"Grep",
"LS",
"Read",
"Edit",
"MultiEdit",
"Write",
"WebFetch",
"WebSearch"
]
}
},
...
}

Note: If following this example ensure you update the right projects configuration.

tip

Multiple configuration locations exist due to legacy compatibility - you might encounter different file names and directory locations.

Recommendation: Use ~/.claude.json for reliability as shown in the examples above.