SOP-004: Installing Claude Code
FreshSource: Claude Code in Action
Document Control
| Field | Value |
|---|---|
| SOP ID | SOP-004 |
| Version | 1.0 |
| Status | Active |
| Last Updated | 2024-12 |
Overview
Install and configure Claude Code, a command-line AI assistant for development tasks.
Prerequisites
- Node.js 18+ installed
- Terminal/Command prompt access
- Anthropic API key
Installation Process
Step 1: Install via npm
bash
npm install -g @anthropic-ai/claude-codeOr use npx (no install):
bash
npx @anthropic-ai/claude-codeStep 2: Configure API Key
bash
# Set environment variable
export ANTHROPIC_API_KEY="sk-ant-api03-..."
# Or configure interactively
claude config set api_key sk-ant-api03-...Step 3: Initialize in Project
bash
cd /path/to/your/project
# Initialize Claude Code
claude /initThis creates a CLAUDE.md file with project context.
Claude Code Architecture
Essential Commands
| Command | Description |
|---|---|
/init | Initialize project context |
/clear | Clear conversation |
/help | Show available commands |
/compact | Reduce context size |
@file.ts | Reference specific file |
Escape | Cancel current operation |
CLAUDE.md File Structure
markdown
# Project: My App
## Overview
Brief description of the project.
## Tech Stack
- Framework: Next.js
- Language: TypeScript
- Database: PostgreSQL
## Key Patterns
- Use functional components
- Follow existing naming conventions
## Important Files
- src/lib/db.ts - Database connection
- src/app/api - API routesVerification Checklist
- [ ] Claude Code installed globally
- [ ] API key configured
- [ ] Project initialized with CLAUDE.md
- [ ] Can run basic commands
- [ ] File references working (@file)
Troubleshooting
| Issue | Solution |
|---|---|
| Command not found | Reinstall or use npx |
| API key invalid | Check key format |
| Permission denied | Check file permissions |
| Context too large | Use /compact |