SOP-002: Claude Code Installation
Document Control
- SOP ID: 002
- Version: 1.0
- Status: Active
- Last Updated: December 2024
- Review Cycle: Monthly
Overview
Complete installation and configuration guide for Claude Code, Anthropic's agentic coding assistant.
Purpose
Standardize the installation, configuration, and optimization of Claude Code across development environments.
Prerequisites
- [ ] Operating System: Windows 10+, macOS 12+, or Linux
- [ ] Node.js 18+ installed
- [ ] Git installed and configured
- [ ] Valid Anthropic API key
- [ ] 4GB+ available disk space
Installation Procedure
┌─────────────────────────────────────────────────────────────────────┐
│ CLAUDE CODE SETUP FLOW │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ [Download] ──► [Install] ──► [Configure] ──► [Verify] │
│ ▼ ▼ ▼ ▼ │
│ Get binary Run setup Set API key Test command │
│ │
│ [Customize] ──► [CLAUDE.md] ──► [Permissions] ──► [Ready] │
│ ▼ ▼ ▼ ▼ │
│ Set aliases Add context Allow tools Start coding │
│ │
└─────────────────────────────────────────────────────────────────────┘Step 1: Download Claude Code
macOS
bash
# Using Homebrew
brew install anthropic/tap/claude-code
# Or direct download
curl -L https://releases.anthropic.com/claude-code/latest/mac -o claude-code
chmod +x claude-code
sudo mv claude-code /usr/local/bin/Windows
powershell
# Using winget
winget install Anthropic.ClaudeCode
# Or PowerShell download
Invoke-WebRequest -Uri "https://releases.anthropic.com/claude-code/latest/win" -OutFile "claude-code.exe"
Move-Item claude-code.exe "C:\Program Files\Claude Code\"
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\Claude Code", "User")Linux
bash
# Debian/Ubuntu
wget https://releases.anthropic.com/claude-code/latest/linux-deb
sudo dpkg -i claude-code_latest_amd64.deb
# Generic Linux
curl -L https://releases.anthropic.com/claude-code/latest/linux -o claude-code
chmod +x claude-code
sudo mv claude-code /usr/local/bin/Step 2: Initial Configuration
bash
# Set API key
claude-code config set api_key sk-ant-api03-...
# Set default model
claude-code config set model claude-3-5-sonnet-20241022
# Configure editor integration
claude-code config set editor vscode # or vim, emacs, etc.
# Set working directory behavior
claude-code config set auto_cd trueStep 3: Create CLAUDE.md File
Create a CLAUDE.md file in your project root:
markdown
# Project: [Your Project Name]
## Overview
Brief description of your project.
## Tech Stack
- Language: Python 3.11
- Framework: FastAPI
- Database: PostgreSQL
- Testing: pytest
## Key Commands
```bash
# Run tests
pytest tests/
# Start dev server
uvicorn main:app --reload
# Build for production
docker build -t myapp .Project Structure
src/
├── api/ # API endpoints
├── models/ # Data models
├── services/ # Business logic
└── utils/ # UtilitiesCoding Conventions
- Use type hints
- Follow PEP 8
- Write docstrings for all functions
- Test coverage minimum: 80%
### Step 4: Configure Permissions
```bash
# Create settings file
mkdir -p ~/.claude
touch ~/.claude/settings.jsonEdit ~/.claude/settings.json:
json
{
"tools": {
"allowlist": [
"bash",
"read",
"write",
"edit",
"grep",
"git"
],
"dangerous_commands": {
"require_confirmation": [
"rm -rf",
"git push --force",
"DROP TABLE",
"DELETE FROM"
]
}
},
"context": {
"max_files": 50,
"exclude_patterns": [
"node_modules/**",
"*.pyc",
".git/**",
"dist/**",
"build/**"
]
},
"safety": {
"container_mode": false,
"backup_before_edit": true,
"max_file_size_mb": 10
}
}Step 5: Install MCP Servers (Optional)
bash
# Install common MCP servers
npm install -g @anthropic/mcp-filesystem
npm install -g @anthropic/mcp-git
npm install -g @anthropic/mcp-web
# Configure MCP
claude-code mcp add filesystem
claude-code mcp add git
claude-code mcp add webStep 6: Verify Installation
bash
# Check version
claude-code --version
# Run diagnostic
claude-code diagnose
# Test basic command
claude-code "What files are in the current directory?"
# Test with specific model
claude-code --model claude-3-5-haiku-20241022 "Hello, Claude Code!"Advanced Configuration
Custom Commands
Create ~/.claude/commands.json:
json
{
"commands": {
"review": "Review this code for bugs, performance, and best practices",
"test": "Write comprehensive unit tests for this code",
"docs": "Generate documentation for this module",
"refactor": "Refactor this code for better readability and maintainability",
"security": "Perform a security audit of this code"
}
}Usage:
bash
claude-code review main.py
claude-code test api/endpoints.pyShell Aliases
Add to ~/.bashrc or ~/.zshrc:
bash
# Claude Code aliases
alias cc='claude-code'
alias ccr='claude-code review'
alias cct='claude-code test'
alias ccd='claude-code docs'
alias ccp='claude-code "Create a pull request with these changes"'
# Quick commands
ccfix() {
claude-code "Fix the error: $1"
}
ccplan() {
claude-code "Create an implementation plan for: $1"
}Troubleshooting
Issue: "Command not found"
bash
# Solution: Add to PATH
export PATH=$PATH:/usr/local/bin
source ~/.bashrcIssue: "API key invalid"
bash
# Solution: Reconfigure
claude-code config set api_key [your-key]
claude-code config verifyIssue: "Permission denied"
bash
# Solution: Check tool permissions
claude-code permissions list
claude-code permissions add bashIssue: "Context too large"
bash
# Solution: Limit context
claude-code --max-files 10 "Your command"
# Or update exclude patterns in settings.jsonBest Practices
- CLAUDE.md Files: Always maintain project-specific CLAUDE.md
- Version Control: Commit .claude/settings.json for team consistency
- Security: Never allow dangerous commands without confirmation
- Context Management: Exclude large/binary files from context
- Backup: Enable backup_before_edit for safety
Performance Optimization
Context Optimization
json
{
"performance": {
"cache_responses": true,
"cache_ttl_minutes": 30,
"parallel_file_reading": true,
"compress_context": true
}
}Resource Limits
json
{
"limits": {
"max_memory_mb": 2048,
"max_cpu_percent": 80,
"timeout_seconds": 300
}
}Verification Checklist
- [ ] Claude Code installed and in PATH
- [ ] API key configured and verified
- [ ] CLAUDE.md file created in project
- [ ] Permissions configured appropriately
- [ ] Shell aliases set up (optional)
- [ ] MCP servers installed (optional)
- [ ] Diagnostic tests pass
- [ ] Can execute basic commands
See Also
- SOP-001: API Setup
- SOP-003: MCP Configuration
- SOP-006: CLAUDE.md Creation
- Workflow-001: Explore-Plan-Code
Next Step: Configure MCP servers with SOP-003: MCP Setup