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 │
│ │
└─────────────────────────────────────────────────────────────────────┘Quick Links
📋 Reference Guides
- API Commands - Complete API reference
- Prompt Templates - Ready-to-use prompts
- Error Codes - Error lookup table
- Troubleshooting - Common issues & fixes
- Best Practices Checklist - Quick validation
- Model Comparison - Model selection guide
- Tool Reference - Available tools & usage
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 handleStreaming Responses
python
with client.messages.stream(...) as stream:
for text in stream.text_stream:
print(text, end="")Model Quick Reference
| Model | Speed | Intelligence | Cost | Use 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.comKeyboard Shortcuts
Claude Code
| Action | Shortcut | Description |
|---|---|---|
| Cancel | Ctrl+C | Stop current operation |
| Clear | Ctrl+L | Clear terminal |
| History | ↑/↓ | Navigate command history |
| Complete | Tab | Autocomplete files/commands |
Quick Debugging
Check Installation
bash
claude-code --version
claude-code diagnose
claude-code config listTest 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
| Model | Requests/min | Tokens/min | Tokens/day |
|---|---|---|---|
| Haiku | 50 | 100,000 | 5,000,000 |
| Sonnet | 40 | 80,000 | 4,000,000 |
| Opus | 20 | 40,000 | 2,000,000 |
Common Error Codes
| Code | Meaning | Quick Fix |
|---|---|---|
| 401 | Invalid API key | Check ANTHROPIC_API_KEY |
| 429 | Rate limit | Implement backoff |
| 500 | Server error | Retry with exponential backoff |
| 503 | Service unavailable | Check 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) // 4Response 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
- API Status: status.anthropic.com
- Support: support@anthropic.com
- Documentation: docs.anthropic.com
- Community: discord.gg/anthropic
Need more details? Check specific guides: