Skip to main content

Overview

Claude Code by Anthropic is one of the most powerful AI coding assistants available. Known for exceptional reasoning, clear explanations, and robust code generation.
Claude 3.5 Sonnet (released Oct 2024) is currently the best all-around model for coding tasks.

Quick Start

1

Get API Key

  1. Go to console.anthropic.com
  2. Sign up or log in
  3. Navigate to API Keys
  4. Click Create Key
  5. Copy your API key (starts with sk-ant-)
2

Configure Forge

Edit .forge/config.json:
{
  "llms": {
    "claude": {
      "apiKey": "sk-ant-api03-...",
      "model": "claude-3-5-sonnet-20241022"
    }
  }
}
3

Test Connection

forge task create \
  --title "Test Claude" \
  --description "Print 'Hello from Claude!'" \
  --llm claude

Available Models

claude-3-5-sonnet-20241022
model
Best all-around model for coding
  • Context: 200K tokens
  • Speed: Fast
  • Cost: 3/MTokinput,3/MTok input, 15/MTok output
  • Best for: Most coding tasks
{
  "llms": {
    "claude": {
      "model": "claude-3-5-sonnet-20241022"
    }
  }
}
claude-3-5-haiku-20241022
model
Fastest and most cost-effective
  • Context: 200K tokens
  • Speed: Very fast (3x faster than Sonnet)
  • Cost: 0.25/MTokinput,0.25/MTok input, 1.25/MTok output
  • Best for: Simple tasks, quick fixes
{
  "llms": {
    "claude-haiku": {
      "apiKey": "sk-ant-...",
      "model": "claude-3-5-haiku-20241022"
    }
  }
}

Claude 3 Family (Legacy)

claude-3-opus-20240229
model
Most powerful, most expensive
  • Context: 200K tokens
  • Speed: Slower
  • Cost: 15/MTokinput,15/MTok input, 75/MTok output
  • Best for: Critical architecture decisions
Opus is 5x more expensive than Sonnet. Use sparingly!

Model Comparison

ModelSpeedQualityCostBest For
3.5 Sonnet⭐⭐⭐⭐⭐⭐⭐⭐⭐$$$Most tasks (recommended)
3.5 Haiku⭐⭐⭐⭐⭐⭐⭐⭐⭐$Quick iterations
3 Opus⭐⭐⭐⭐⭐⭐⭐⭐$$$$$Critical work only

Configuration Options

Basic Configuration

{
  "llms": {
    "claude": {
      "apiKey": "sk-ant-api03-...",
      "model": "claude-3-5-sonnet-20241022"
    }
  }
}

Advanced Configuration

{
  "llms": {
    "claude": {
      "apiKey": "sk-ant-api03-...",
      "model": "claude-3-5-sonnet-20241022",
      "maxTokens": 8192,
      "temperature": 0.7,
      "timeout": 60000,
      "retries": 3,
      "baseUrl": "https://api.anthropic.com"
    }
  }
}
maxTokens
number
default:"4096"
Maximum tokens in response
  • Min: 1
  • Max: 8192
  • Higher = longer responses, more cost
temperature
number
default:"1.0"
Randomness of responses (0-1)
  • 0 = Deterministic, consistent
  • 1 = Creative, varied
  • 0.7 = Good balance
timeout
number
default:"60000"
Request timeout in milliseconds
retries
number
default:"3"
Number of retry attempts on failure

Claude’s Strengths

Complex Reasoning

Claude excels at multi-step logic:
forge task create \
  --title "Design authentication system" \
  --description "
  Design a complete auth system with:
  - JWT token management
  - Refresh token rotation
  - Role-based access control
  - Session management
  - Password reset flow

  Consider security, scalability, and maintainability.
  " \
  --llm claude
Claude will:
  • Break down the problem systematically
  • Consider edge cases
  • Suggest architectural patterns
  • Explain trade-offs

Code Refactoring

Claude maintains code coherence during refactoring:
forge task create \
  --title "Refactor user service to clean architecture" \
  --description "
  Current: Monolithic UserService with 800 lines
  Goal: Clean architecture with:
  - Separate domain, application, infrastructure layers
  - Dependency injection
  - Unit testable components

  Preserve all existing functionality.
  " \
  --llm claude

Security-Aware

Claude considers security implications:
forge task create \
  --title "Add file upload endpoint" \
  --description "
  Allow users to upload profile pictures
  " \
  --llm claude
Claude will add:
  • File type validation
  • Size limits
  • Malware scanning considerations
  • Secure file storage
  • Path traversal protection

Claude’s Weaknesses

Can Be Verbose

Claude sometimes over-explains: Solution: Use concise prompts:
forge task create \
  --title "Add validation" \
  --description "Add email validation. Keep it simple." \
  --llm claude

May Over-Engineer

For simple tasks, Claude might create complex solutions: Solution: Use Haiku for simple tasks:
forge task create \
  --title "Add console.log for debugging" \
  --llm claude-haiku

Pricing & Cost Management

Current Pricing (as of Oct 2024)

ModelInputOutputExample Cost
3.5 Sonnet$3/MTok$15/MTok10K context + 2K response = $0.06
3.5 Haiku$0.25/MTok$1.25/MTok10K context + 2K response = $0.005
3 Opus$15/MTok$75/MTok10K context + 2K response = $0.30

Cost Optimization

  • Use Haiku First
  • Reduce Context
  • Lower Max Tokens
  • Monitor Spending
# Start with Haiku
forge task create "Add button" --llm claude-haiku

# If not good enough, try Sonnet
forge task fork 1 --llm claude
Saves money on simple tasks

Best Practices

Task Descriptions

Claude responds well to structured descriptions: Good ✅:
forge task create \
  --title "Add caching" \
  --description "
  # Goal
  Add Redis caching to product API

  # Requirements
  - Cache GET /api/products for 5 minutes
  - Invalidate on POST/PUT/DELETE
  - Handle Redis connection errors gracefully

  # Constraints
  - Don't cache user-specific data
  - Keep existing API contract unchanged
  " \
  --llm claude
Bad ❌:
forge task create \
  --title "make it faster" \
  --description "add cache or something" \
  --llm claude

Using Multiple Claude Models

# Quick exploration with Haiku
forge task create "Add dark mode" --llm claude-haiku

# Refined implementation with Sonnet
forge task fork 1 --llm claude

# Critical review with Opus
forge task fork 1 --llm claude-opus

Integration with Forge

MCP Support

Claude Code works seamlessly with Forge’s MCP server:
// In Claude Code settings
{
  "mcpServers": {
    "automagik-forge": {
      "command": "npx",
      "args": ["automagik-forge", "--mcp"],
      "env": {
        "PROJECT_ID": "your-project-id"
      }
    }
  }
}
Now you can:
You: "Create a task to add user authentication"
Claude Code: [Uses MCP to create task in Forge]

Specialized Profiles

Create Claude variants for specific tasks:
{
  "llms": {
    "claude": {
      "model": "claude-3-5-sonnet-20241022"
    },
    "claude-security": {
      "model": "claude-3-5-sonnet-20241022",
      "systemPrompt": "You are a security expert. Always consider security implications..."
    },
    "claude-tester": {
      "model": "claude-3-5-sonnet-20241022",
      "systemPrompt": "You are a testing expert. Write comprehensive tests..."
    }
  }
}

Troubleshooting

Error: “Invalid API key”Solutions:
  • Verify API key is correct (starts with sk-ant-api03-)
  • Check for extra spaces or quotes
  • Ensure key hasn’t been rotated
  • Generate new key from console.anthropic.com
Error: “Rate limit exceeded”Solutions:
  • Wait a few minutes
  • Reduce concurrent tasks
  • Upgrade Anthropic plan for higher limits
  • Use exponential backoff:
{
  "llms": {
    "claude": {
      "retries": 5,
      "retryDelay": 1000
    }
  }
}
Issue: Claude taking too longSolutions:
  • Use Haiku instead of Sonnet
  • Reduce maxTokens
  • Simplify task description
  • Check network latency
Error: “Prompt is too long”Solutions:
  • Reduce context sent to Claude
  • Don’t include entire codebase
  • Use --files to limit scope
  • Split into smaller tasks
Issue: Different results each timeNormal behavior! AI is non-deterministic.For consistency:
{
  "llms": {
    "claude": {
      "temperature": 0
    }
  }
}

Rate Limits

Anthropic API Limits

TierRPMTPMTPD
Free510K100K
Build (Tier 1)5040K1M
Scale (Tier 2)100080K2.5M
EnterpriseCustomCustomCustom
RPM = Requests per minute TPM = Tokens per minute TPD = Tokens per day Check your tier: console.anthropic.com/settings/limits

Advanced Features

Streaming Responses

Watch Claude’s output in real-time:
forge task start 1 --llm claude --stream

Vision Support

Claude can analyze images:
forge task create \
  --title "Implement this design" \
  --attach mockup.png \
  --llm claude

Extended Thinking

For complex problems, enable extended thinking:
{
  "llms": {
    "claude": {
      "thinkingTokens": 10000
    }
  }
}

Comparison with Other Agents

FeatureClaude 3.5GPT-4Gemini Pro
Context200K128K2M
Reasoning⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
Speed⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
Cost$$$$$$$$$
Code Quality⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
Claude wins: Complex reasoning, architecture, security GPT-4 wins: Consistency, documentation Gemini wins: Speed, cost, context window

Real-World Examples

Example 1: API Refactoring

forge task create \
  --title "Refactor REST API to GraphQL" \
  --description "
  Current: 15 REST endpoints in src/api/
  Goal: Single GraphQL endpoint with:
  - Schema matching REST capabilities
  - Resolvers for all queries/mutations
  - DataLoader for N+1 prevention
  - Maintain backward compatibility via REST wrapper
  " \
  --llm claude
Result: Claude created comprehensive GraphQL schema, resolvers, and maintained REST compatibility.

Example 2: Security Audit

forge task create \
  --title "Security audit of payment processing" \
  --description "
  Review src/payment/ for security issues:
  - Input validation
  - SQL injection
  - XSS vulnerabilities
  - Sensitive data exposure
  - Rate limiting
  " \
  --llm claude
Result: Claude identified 7 security issues with detailed explanations and fixes.

Next Steps