/ 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

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "anthropic-cookbook-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anthropics/anthropic-cookbook",
        "~/.claude/skills/anthropic-cookbook"
      ],
      "_inferred": true
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "anthropic-cookbook-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anthropics/anthropic-cookbook",
        "~/.claude/skills/anthropic-cookbook"
      ],
      "_inferred": true
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "anthropic-cookbook-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anthropics/anthropic-cookbook",
        "~/.claude/skills/anthropic-cookbook"
      ],
      "_inferred": true
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "anthropic-cookbook-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anthropics/anthropic-cookbook",
        "~/.claude/skills/anthropic-cookbook"
      ],
      "_inferred": true
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "anthropic-cookbook-skill",
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anthropics/anthropic-cookbook",
        "~/.claude/skills/anthropic-cookbook"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "anthropic-cookbook-skill": {
      "command": {
        "path": "git",
        "args": [
          "clone",
          "https://github.com/anthropics/anthropic-cookbook",
          "~/.claude/skills/anthropic-cookbook"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add anthropic-cookbook-skill -- git clone https://github.com/anthropics/anthropic-cookbook ~/.claude/skills/anthropic-cookbook

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

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