BeClaude
Guide2026-04-27

The Complete Guide to Claude Cookbooks: Building with Anthropic's Official Recipes

Learn how to set up, develop, and contribute to Anthropic's Claude Cookbooks. Master the development workflow, code style, model selection, and best practices for building Claude-powered applications.

Quick Answer

This guide walks you through setting up and using Anthropic's official Claude Cookbooks repository. You'll learn the development environment setup, code formatting rules, model selection guidelines, and how to contribute your own cookbook notebooks to the community.

Claude APICookbooksDevelopment WorkflowBest PracticesAnthropic

The Complete Guide to Claude Cookbooks: Building with Anthropic's Official Recipes

Anthropic's Claude Cookbooks repository is the definitive resource for developers building applications with the Claude API. This collection of Jupyter notebooks and Python examples provides ready-to-use recipes for everything from basic API calls to advanced patterns like tool use, multimodal processing, and extended thinking.

Whether you're a Claude newcomer or an experienced builder, this guide will help you navigate the cookbook ecosystem, set up your development environment, and even contribute your own recipes.

What Are Claude Cookbooks?

The Claude Cookbooks repository (github.com/anthropics/anthropic-cookbook) is a curated collection of practical, runnable examples organized by capability. Each notebook demonstrates a specific concept—like Retrieval-Augmented Generation (RAG), classification, tool use, or vision processing—with real, working code.

The repository is structured into clear categories:

  • capabilities/ — Core Claude capabilities (RAG, classification, etc.)
  • skills/ — Advanced skill-based notebooks
  • tool_use/ — Tool use and integration patterns
  • multimodal/ — Vision and image processing
  • extended_thinking/ — Extended reasoning patterns
  • misc/ — Batch processing, caching, utilities
  • third_party/ — Integrations with Pinecone, Voyage, Wikipedia, and more
This structure makes it easy to find exactly what you need, whether you're building a chatbot, an analysis tool, or a multimodal application.

Setting Up Your Development Environment

Before diving into the cookbooks, you need to set up your local environment. The repository uses uv as its package manager and ruff for code formatting and linting.

Step 1: Install Dependencies

# Install all dependencies including extras
uv sync --all-extras

Install pre-commit hooks for automated quality checks

uv run pre-commit install

Step 2: Configure Your API Key

# Copy the example environment file
cp .env.example .env

Edit .env and add your ANTHROPIC_API_KEY

Never commit .env files to version control!

Step 3: Verify Your Setup

Run the quality checks to ensure everything is working:

make check

This runs both formatting checks and linting. If everything passes, you're ready to start exploring the cookbooks.

Development Commands at a Glance

The repository provides several make commands to streamline your workflow:

CommandPurpose
make formatFormat code with ruff
make lintRun linting checks
make checkRun format-check + lint together
make fixAuto-fix issues + format
make testRun pytest tests
You can also use uv directly:
uv run ruff format .           # Format all files
uv run ruff check .            # Lint all files
uv run ruff check --fix .      # Auto-fix linting issues
uv run pre-commit run --all-files  # Run all pre-commit hooks

Code Style and Best Practices

The cookbook repository enforces a consistent code style to maintain quality across contributions:

  • Line length: 100 characters
  • Quotes: Double quotes (")
  • Formatter: Ruff (replaces Black and isort)
Notebooks have slightly relaxed rules for certain patterns:
  • Mid-file imports (E402) are allowed
  • Redefinitions (F811) are permitted
  • Variable naming conventions (N803, N806) are relaxed
This flexibility acknowledges that notebooks often need to import libraries mid-execution or use descriptive variable names that don't follow strict Python conventions.

Choosing the Right Claude Model

One of the most critical decisions when building with Claude is selecting the right model. The cookbook repository provides clear guidance on which models to use and, importantly, which model IDs to avoid.

Current Model Aliases (Recommended)

# Use these non-dated aliases for API calls
SONNET = "claude-sonnet-4-6"
HAIKU = "claude-haiku-4-5"
OPUS = "claude-opus-4-6"
Never use dated model IDs like claude-sonnet-4-6-20250514. Always use the non-dated alias. This ensures your application automatically receives model updates and improvements without code changes.

Bedrock Model IDs

If you're using Amazon Bedrock, the model IDs follow a different format:

# Bedrock model IDs (recommended: prepend 'global.' for global endpoints)
OPUS_BEDROCK = "global.anthropic.claude-opus-4-6-v1"
SONNET_BEDROCK = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
HAIKU_BEDROCK = "global.anthropic.claude-haiku-4-5-20251001-v1:0"

Note that Bedrock models before Opus 4.6 require dated IDs in their Bedrock model ID format. Always check the Anthropic documentation for the latest model versions.

Working with Notebooks

The cookbook notebooks are designed to be educational and runnable. Here are the key rules:

  • Keep outputs in notebooks — Unlike typical Jupyter best practices, cookbook notebooks intentionally retain their outputs for demonstration purposes.
  • One concept per notebook — Each notebook should focus on a single capability or pattern, making it easy to understand and reuse.
  • Test top-to-bottom — Every notebook must run without errors from the first cell to the last. This ensures reliability for users.
  • Run quality checks — Before committing, run make check to validate formatting and notebook structure.

Slash Commands for Quality Assurance

The repository includes Claude Code slash commands that automate quality checks:

  • /notebook-review — Reviews notebook quality and structure
  • /model-check — Validates Claude model references (catches dated model IDs)
  • /link-review — Checks links in changed files
These commands are available both in Claude Code and in CI pipelines, ensuring consistent quality across all contributions.

Contributing a New Cookbook

One of the best ways to learn is to contribute your own cookbook. Here's the process:

Step 1: Create Your Notebook

Place your notebook in the appropriate directory based on its capability:

  • capabilities/ for core features
  • skills/ for advanced patterns
  • tool_use/ for tool integration examples
  • etc.

Step 2: Register Your Cookbook

Add an entry to registry.yaml with:

  • title — A clear, descriptive title
  • description — What the notebook demonstrates
  • path — File path to the notebook
  • authors — GitHub usernames of contributors
  • categories — Tags for discoverability

Step 3: Add Author Information

If you're a new contributor, add your information to authors.yaml.

Step 4: Submit a Pull Request

Before submitting:

  • Run make check to ensure quality
  • Verify your notebook runs top-to-bottom
  • Follow the commit format: feat(scope): add new feature

Git Workflow

  • Branch naming: <username>/<feature-description> (e.g., johndoe/rag-cookbook)
  • Commit format: Use conventional commits:
- feat(scope): add new feature - fix(scope): fix bug - docs(scope): update documentation - style: lint/format

Practical Example: Your First Cookbook Notebook

Here's a minimal example of what a cookbook notebook might look like:

# cell 1: Setup
import os
from dotenv import load_dotenv
from anthropic import Anthropic

load_dotenv() client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))

cell 2: Define the model

MODEL_NAME = "claude-sonnet-4-6" # Always use non-dated alias

cell 3: Make an API call

response = client.messages.create( model=MODEL_NAME, max_tokens=1024, messages=[ {"role": "user", "content": "Hello, Claude!"} ] )

print(response.content[0].text)

This pattern—setup, configuration, execution—is the foundation of every cookbook notebook.

Key Takeaways

  • Use the official setup: Install dependencies with uv sync --all-extras and configure your API key via .env file. Never commit API keys to version control.
  • Always use non-dated model aliases (e.g., claude-sonnet-4-6) instead of dated IDs to ensure automatic updates and compatibility.
  • Follow the code style: 100-character line length, double quotes, and Ruff formatting. Run make check before every commit.
  • Contribute with structure: Place notebooks in the correct directory, register them in registry.yaml, and follow conventional commit format for pull requests.
  • Leverage slash commands: Use /notebook-review, /model-check, and /link-review to automate quality assurance in your workflow.