Skip to content

Quick Reference

Fast lookup guides for common Claude AI operations, commands, and troubleshooting.

┌─────────────────────────────────────────────────────────────────────┐
│                        QUICK REFERENCE HUB                           │
├─────────────────────────────────────────────────────────────────────┤
│                                                                      │
│   Commands & APIs         Templates & Patterns      Troubleshooting │
│   ───────────────        ────────────────────      ──────────────  │
│   • API Endpoints         • Prompt Templates        • Error Codes   │
│   • CLI Commands          • Code Patterns           • Common Issues │
│   • Model Parameters      • System Prompts          • Solutions     │
│                                                                      │
└─────────────────────────────────────────────────────────────────────┘

📋 Reference Guides

Most Used Commands

Claude API

python
# Quick initialization
from anthropic import Anthropic
client = Anthropic()

# Basic message
response = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Your prompt"}]
)

Claude Code CLI

bash
# Basic commands
claude-code "What's in this directory?"
claude-code review main.py
claude-code test api/
claude-code "Fix the error in line 42"

# With options
claude-code --model haiku "Quick task"
claude-code --max-tokens 2000 "Long response needed"
claude-code --temperature 0.2 "Precise code generation"

Common Patterns

Error Handling

python
try:
    response = client.messages.create(...)
except RateLimitError:
    # Wait and retry
except AuthenticationError:
    # Check API key
except Exception as e:
    # Log and handle

Streaming Responses

python
with client.messages.stream(...) as stream:
    for text in stream.text_stream:
        print(text, end="")

Model Quick Reference

ModelSpeedIntelligenceCostUse Case
Haiku 4.5⚡⚡⚡★★★$Quick responses, simple tasks
Sonnet 4.5⚡⚡★★★★$$Balanced, general purpose
Opus 4.5★★★★★$$$Complex reasoning, coding

Environment Variables

bash
# Essential
ANTHROPIC_API_KEY=sk-ant-api03-...

# Optional
ANTHROPIC_MODEL=claude-3-5-sonnet-20241022
ANTHROPIC_MAX_TOKENS=4096
ANTHROPIC_TEMPERATURE=0.7
ANTHROPIC_BASE_URL=https://api.anthropic.com

Keyboard Shortcuts

Claude Code

ActionShortcutDescription
CancelCtrl+CStop current operation
ClearCtrl+LClear terminal
History↑/↓Navigate command history
CompleteTabAutocomplete files/commands

Quick Debugging

Check Installation

bash
claude-code --version
claude-code diagnose
claude-code config list

Test Connection

python
# test_quick.py
from anthropic import Anthropic
client = Anthropic()
print(client.messages.create(
    model="claude-3-5-haiku-20241022",
    max_tokens=10,
    messages=[{"role": "user", "content": "Hi"}]
).content[0].text)

Rate Limits

ModelRequests/minTokens/minTokens/day
Haiku50100,0005,000,000
Sonnet4080,0004,000,000
Opus2040,0002,000,000

Common Error Codes

CodeMeaningQuick Fix
401Invalid API keyCheck ANTHROPIC_API_KEY
429Rate limitImplement backoff
500Server errorRetry with exponential backoff
503Service unavailableCheck status.anthropic.com

Useful Snippets

Retry Logic

python
import time
def retry(func, retries=3):
    for i in range(retries):
        try:
            return func()
        except Exception as e:
            if i == retries - 1: raise
            time.sleep(2 ** i)

Token Counter

python
def estimate_tokens(text):
    # Rough estimation
    return len(text) // 4

Response Parser

python
def parse_code_blocks(response):
    import re
    pattern = r'```(?:\w+)?\n(.*?)\n```'
    return re.findall(pattern, response, re.DOTALL)

Quick Templates

System Prompt

python
system = "You are a helpful AI assistant skilled in Python and web development."

Code Review

python
prompt = f"Review this code for bugs and improvements:\n```python\n{code}\n```"

Test Generation

python
prompt = f"Write comprehensive unit tests for:\n```python\n{code}\n```"

Emergency Contacts


Need more details? Check specific guides:

Claude Code Documentation Hub