/ Directory / Playground / Anthropic Cookbook
● Official anthropics ⚡ Instant

Anthropic Cookbook

by anthropics · anthropics/anthropic-cookbook

Anthropic's official recipe book for Claude — caching, batching, RAG, agents, multimodal, citations — with runnable notebooks.

anthropics/anthropic-cookbook is the official recipe collection for the Claude API. Each recipe is a focused notebook: prompt caching, message batching, agentic loops, RAG with citations, multimodal vision, classification, and evaluation. Use it as a skill resource so Claude can ground implementation suggestions in tested examples.

Why use it

Key features

Live Demo

What it looks like in practice

ready

Install

Author repository · Claude Skills documentation

Use Cases

Real-world ways to use Anthropic Cookbook

Add prompt caching to cut your Claude API bill

👤 Engineers running Claude in production ⏱ ~60 min intermediate

When to use: API spend is climbing and you have repeated context per request.

Flow
  1. Read the recipe
    Use anthropic-cookbook. Show me the prompt caching pattern for repeated system prompts.✓ Copied
    → Cache_control example
  2. Apply to my code
    Adapt to my service that re-sends a 5k-token style guide every call.✓ Copied
    → Cached system prompt; cost projection
  3. Verify the savings
    Measure cache hit rate and cost delta over 100 calls.✓ Copied
    → Concrete cost reduction

Outcome: Real cost savings (~50-80% on cached portion).

Pitfalls
  • Cache lifetime is short — high-traffic workloads benefit most — Low-traffic API may not see hits; calibrate before optimizing

Move offline scoring jobs to message batching for 50% off

👤 Teams running large eval/classification jobs ⏱ ~45 min intermediate

When to use: Job is async and you have >100 calls.

Flow
  1. Use the batch recipe
    Apply batching from the cookbook to my classification job.✓ Copied
    → Batch endpoint integration shown
  2. Verify completion + cost
    Compare batched cost vs sync for 1000 prompts.✓ Copied
    → Cost cut by ~50%

Outcome: Cheaper offline workloads, same accuracy.

Build a RAG system that cites its sources properly

👤 Devs building Q&A over docs ⏱ ~90 min intermediate

When to use: Users will challenge answers; you need citations they can verify.

Flow
  1. Adopt the citations pattern
    Use the citations recipe. Apply to my doc set.✓ Copied
    → Answers reference source IDs
  2. Add inline links
    Map source IDs to URLs so users can click through.✓ Copied
    → Linkified citations

Outcome: Trustworthy RAG with audit trail.

Combinations

Pair with other MCPs for X10 leverage

anthropic-cookbook-skill + anthropic-courses-skill

Cookbook = practice, courses = theory

Read the eval course chapter, then lift the cookbook eval harness for your prompt.✓ Copied
anthropic-cookbook-skill + anthropic-quickstarts-skill

App skeleton + cookbook recipes

Quickstart the customer-support template, then layer in caching from cookbook.✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
(notebook recipes) natural lookup When facing a known Claude pattern 0

Cost & Limits

What this costs to run

API quota
Recipes call the API — usage charges apply when running
Tokens per call
Variable per recipe
Monetary
Free (MIT)
Tip
Use Sonnet during dev; switch to Opus only for prompts that need it

Security

Permissions, secrets, blast radius

Minimum scopes: anthropic-api-key
Credential storage: ANTHROPIC_API_KEY in env
Data egress: Anthropic API

Troubleshooting

Common errors and fixes

Recipe uses old SDK version

Bump anthropic SDK; minor API changes may need 2-line updates

Cache hits show 0 in production

Cache key is content-sensitive; even a single token diff = miss. Stabilize prefixes.

Alternatives

Anthropic Cookbook vs others

AlternativeWhen to use it insteadTradeoff
anthropics/anthropic-quickstartsYou want full apps, not recipesDifferent grain
anthropics/coursesYou want pedagogy, not implementationTheory vs practice

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills

Continue exploring

Related tools and workflows

Choose another guide for your workflow, or explore a collection.

Browse all topic collections → · See 29 new official additions →