Claude AI Cheat Sheet

Last Updated: November 21, 2025

Claude Models Overview

Claude 3.5 Sonnet
Most intelligent model, best for complex tasks
Claude 3 Opus
Previous flagship model, highly capable
Claude 3 Sonnet
Balanced performance and speed
Claude 3 Haiku
Fastest model, best for simple tasks
200K token context window
Approximately 150,000 words or 500+ pages
Vision capabilities
All Claude 3+ models can analyze images

Effective Prompting Techniques

Be clear and direct: "Write a Python function that..."
Start with explicit instructions
Use XML tags: <document>...</document>
Structure prompts with XML for clarity
Provide examples: "Input: X, Output: Y"
Few-shot learning with examples
Assign roles: "You are an expert software architect"
Set context with role assignment
Chain of thought: "Let's think step by step"
Request explicit reasoning process
Use system prompts for consistent behavior
Set guidelines in system message (API)
Break complex tasks into subtasks
Decompose problems for better results
Specify output format: "Respond in JSON"
Request structured output format
Use prefilling: Start assistant response yourself
Guide response format (API only)
Add constraints: "In under 200 words"
Set length or style constraints

Advanced Prompting Patterns

<thinking>...</thinking> then <answer>...</answer>
Separate reasoning from final answer
Constitutional AI: "Be helpful, harmless, and honest"
Claude's training principles
Multi-turn refinement: Ask follow-up questions
Iteratively improve responses
Use delimiters: "Text between ### markers"
Clearly separate different content sections
Negative examples: "Don't do X, instead do Y"
Show what to avoid
Self-consistency: "Generate 3 solutions, then pick best"
Multiple reasoning paths for reliability
Metacognitive prompting: "Explain your confidence level"
Request uncertainty assessment
Retrieval augmentation: Provide relevant documents
Include context in large context window

Claude API Features

POST /v1/messages
Main API endpoint for completions
{"model": "claude-3-5-sonnet-20241022"}
Specify model version
{"max_tokens": 4096}
Set maximum response length
{"temperature": 0.7}
Control randomness (0-1)
{"top_p": 0.9}
Nucleus sampling parameter
{"top_k": 40}
Limit token selection pool
{"stop_sequences": ["\\n\\nHuman:"]}
Custom stop sequences
{"stream": true}
Enable streaming responses
{"system": "You are a helpful assistant"}
Set system prompt for conversation
{"metadata": {"user_id": "123"}}
Add custom metadata for tracking

Vision Capabilities

{"type": "image", "source": {"type": "base64", "media_type": "image/jpeg", "data": "..."}}
Send base64 encoded image
{"type": "image", "source": {"type": "url", "url": "https://..."}}
Send image via URL
Support: JPEG, PNG, GIF, WebP
Supported image formats
Max size: 5MB per image
Image size limit
Multiple images: Up to 20 per request
Multi-image analysis
"Describe this image in detail"
Image description prompts
"Extract text from this screenshot"
OCR capabilities
"Compare these two charts"
Multi-image comparison

Use Cases & Applications

Code generation and debugging
Write, review, and fix code
Content creation and editing
Write articles, emails, documentation
Data analysis and insights
Analyze datasets, generate reports
Customer support automation
Answer questions, troubleshoot issues
Research and summarization
Summarize documents, extract key points
Language translation
Translate between languages
Creative writing and brainstorming
Generate ideas, stories, marketing copy
Education and tutoring
Explain concepts, answer questions
Document processing
Extract structured data from text
Task automation
Automate repetitive text-based tasks

Claude vs GPT-4

Context window: 200K vs 128K tokens
Claude has larger context window
Safety: Constitutional AI training
Claude emphasizes helpfulness and harmlessness
Coding: Strong in both, Claude excels at complex logic
Comparable code generation abilities
Transparency: Claude more likely to admit uncertainty
Different approaches to unknowns
Document analysis: Claude better with long documents
Leverages larger context window
Response style: Claude tends to be more conversational
Different communication styles
Pricing: Similar tier-based pricing
Comparable cost structures
Tool use: Both support function calling
Similar extensibility features

Best Practices

Start simple, iterate based on results
Progressively refine prompts
Use Claude 3.5 Sonnet for complex reasoning
Choose appropriate model for task
Use Haiku for high-volume simple tasks
Optimize costs with right model
Test prompts with diverse inputs
Validate prompt robustness
Cache system prompts for efficiency (API)
Reduce costs with prompt caching
Set temperature=0 for deterministic outputs
Consistency for production tasks
Monitor token usage and costs
Track API consumption
Handle rate limits with exponential backoff
Implement retry logic
Validate and sanitize outputs
Always verify AI responses
Use streaming for better UX in chat applications
Show responses as they generate

Common Prompt Patterns

"Analyze the following text: <text>...</text>"
Text analysis pattern
"Convert this <input>...</input> to <format>JSON</format>"
Format conversion pattern
"Given <context>...</context>, answer: <question>...</question>"
Context-based Q&A pattern
"Compare <option1>...</option1> and <option2>...</option2>"
Comparison pattern
"Classify <text>...</text> into categories: [A, B, C]"
Classification pattern
"Extract <field>name</field> from <text>...</text>"
Information extraction pattern
"Rewrite <text>...</text> to be more <style>formal</style>"
Style transformation pattern
"Debug this code: <code>...</code> Error: <error>...</error>"
Debugging pattern

Error Handling & Limitations

Knowledge cutoff: April 2024
Claude's training data cutoff date
Cannot browse the internet in real-time
No live web access
Cannot execute code or run calculations
Text-only processing
May decline harmful or unethical requests
Safety guardrails in place
Can make mistakes - always verify critical information
Not infallible, use with care
Rate limits: Varies by tier and model
API usage restrictions apply
HTTP 429: Rate limit exceeded
Implement exponential backoff
HTTP 529: Overloaded
Service temporarily unavailable
Pro Tip: Leverage Claude's 200K context window to include entire codebases or documents in your prompts. Use XML tags to structure complex prompts clearly. For production applications, set temperature=0 for consistent outputs and implement prompt caching to reduce costs!
← Back to Data Science & ML | Browse all categories | View all cheat sheets