BeClaude
Guide2026-04-22

The Complete Guide to the Anthropic Cookbook: Building Production-Ready Claude Applications

Learn how to set up, develop, and contribute to the Anthropic Cookbook—a collection of Jupyter notebooks and Python examples for building with the Claude API. Includes setup, code style, model best practices, and contribution workflow.

Quick Answer

This guide walks you through setting up the Anthropic Cookbook repository, understanding its code style and project structure, using correct Claude model IDs, running quality checks, and contributing new cookbook notebooks.

Claude APIAnthropic CookbookJupyter NotebooksPython DevelopmentBest Practices

The Complete Guide to the Anthropic Cookbook: Building Production-Ready Claude Applications

If you're building with the Claude API, the Anthropic Cookbook is your essential companion. This official repository contains a growing collection of Jupyter notebooks and Python examples that demonstrate everything from basic API usage to advanced patterns like tool use, multimodal processing, and extended reasoning.

But the Cookbook isn't just a collection of examples—it's a well-engineered project with strict quality standards, a clear contribution workflow, and best practices that mirror production Claude development. This guide will walk you through everything you need to know to use the Cookbook effectively, whether you're a beginner exploring Claude's capabilities or an experienced developer contributing new notebooks.

Getting Started with the Cookbook

Prerequisites

Before diving in, make sure you have:

  • Python 3.10+ installed
  • An Anthropic API key (get one at console.anthropic.com)
  • Git for cloning the repository
  • uv (the fast Python package manager) installed

Installation

The Cookbook uses uv for dependency management, which is significantly faster than traditional tools like pip or poetry. Here's how to get set up:

# Clone the repository
git clone https://github.com/anthropics/anthropic-cookbook.git
cd anthropic-cookbook

Install all dependencies (including dev dependencies)

uv sync --all-extras

Install pre-commit hooks for automated quality checks

uv run pre-commit install

Set up your environment variables

cp .env.example .env

Edit .env and add your ANTHROPIC_API_KEY

Your First Notebook

Once installed, you can open any notebook in the repository. For a quick start, try the basic classification notebook:

# Start Jupyter
uv run jupyter notebook

Navigate to capabilities/classification/ and open the notebook

Or run a notebook headlessly:

uv run jupyter nbconvert --to notebook --execute capabilities/classification/basic_classification.ipynb

Understanding the Project Structure

The Cookbook is organized into logical directories, each focusing on a specific Claude capability or integration pattern:

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/       # Pinecone, Voyage, Wikipedia integrations
scripts/           # Validation scripts
.claude/           # Claude Code commands and skills

This structure makes it easy to find relevant examples. If you're working on a RAG application, head to capabilities/. If you need vision processing, check multimodal/. The organization mirrors real-world Claude development patterns.

Code Style and Quality Standards

The Cookbook enforces strict code quality standards to ensure consistency across all contributions. Understanding these will help you write better Claude applications in general.

Python Code Style

  • Line length: 100 characters (not the standard 88)
  • Quotes: Double quotes preferred
  • Formatter: Ruff (a fast Rust-based linter/formatter)
Notebooks have relaxed rules for:
  • Mid-file imports (E402)
  • Redefinitions (F811)
  • Variable naming (N803, N806)

Running Quality Checks

Before submitting any changes, run the full quality check suite:

make check        # Format-check + lint
make format       # Auto-format code
make lint         # Run linting only
make fix          # Auto-fix issues + format
make test         # Run pytest

Or using 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

Claude Model Best Practices

One of the most important sections of the Cookbook is its guidance on Claude model IDs. Using the correct model identifiers is crucial for both API and Bedrock users.

API Model IDs (Anthropic API)

Always use the non-dated alias for the latest model versions:

# ✅ CORRECT: Use non-dated aliases
model = "claude-sonnet-4-6"
model = "claude-haiku-4-5"
model = "claude-opus-4-6"

❌ WRONG: Never use dated model IDs

model = "claude-sonnet-4-6-20250514" # This will break when updated

Bedrock Model IDs

Bedrock uses a different naming convention. Always reference the official documentation for the latest IDs:

# ✅ CORRECT: Bedrock model IDs
model = "anthropic.claude-opus-4-6-v1"
model = "anthropic.claude-sonnet-4-5-20250929-v1:0"
model = "anthropic.claude-haiku-4-5-20251001-v1:0"

✅ For global endpoints (recommended)

model = "global.anthropic.claude-opus-4-6-v1"
Important note: Bedrock models before Opus 4.6 require dated IDs in their Bedrock model ID format. Always check docs.anthropic.com for the latest model versions.

Git Workflow and Commit Conventions

The Cookbook follows a structured Git workflow that's worth adopting for your own Claude projects:

Branch Naming

<username>/<feature-description>

Example: johndoe/add-vision-classification

Commit Format (Conventional Commits)

feat(scope): add new feature
fix(scope): fix bug
docs(scope): update documentation
style: lint/format

Examples:

feat(tool_use): add weather API integration notebook
fix(capabilities): correct model ID in RAG example
docs: update README with new directory structure

Key Rules for Cookbook Development

1. API Key Security

Never commit .env files. Always use environment variables:

import os
from dotenv import load_dotenv

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

Or use os.environ directly

2. Dependency Management

Always use uv add to add dependencies—never edit pyproject.toml directly:

uv add pandas          # Production dependency
uv add --dev pytest    # Development dependency

3. Notebook Best Practices

  • Keep outputs in notebooks—they serve as demonstration
  • One concept per notebook—keep focused
  • Test top-to-bottom—notebooks must run without errors

4. Pre-commit Validation

Before committing, run make check. The pre-commit hooks will validate:

  • Code formatting
  • Notebook structure
  • Model ID references
  • Link validity

Slash Commands for Claude Code

The Cookbook includes custom slash commands that work with Claude Code and CI:

  • /notebook-review - Review notebook quality
  • /model-check - Validate Claude model references
  • /link-review - Check links in changed files
These commands automate quality assurance, making it easier to maintain high standards across contributions.

How to Contribute a New Cookbook

Adding a new notebook to the Cookbook is straightforward if you follow these steps:

Step 1: Create Your Notebook

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

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

Step 2: Register Your Notebook

Add an entry to registry.yaml with:

- title: "Your Notebook Title"
  description: "Brief description of what this notebook demonstrates"
  path: capabilities/your-notebook.ipynb
  authors:
    - username: "your-github-username"
  categories:
    - "Your Category"

Step 3: Add Author Info

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

your-github-username:
  name: "Your Name"
  url: "https://github.com/your-github-username"

Step 4: Quality Check and Submit

make check

Fix any issues, then submit your PR

Practical Example: Using the Cookbook in Your Workflow

Here's how I use the Cookbook in my daily Claude development:

  • Explore capabilities by browsing the capabilities/ directory
  • Copy patterns from relevant notebooks into my own code
  • Run quality checks using the same make check workflow
  • Contribute back when I discover useful patterns
The Cookbook isn't just a reference—it's a living repository of best practices that evolves with the Claude platform.

Key Takeaways

  • Use the Cookbook as your primary reference for Claude API patterns—it's maintained by Anthropic and reflects current best practices
  • Always use non-dated model aliases (e.g., claude-sonnet-4-6) to ensure your code works with the latest model versions
  • Run make check before committing to catch formatting issues, invalid model IDs, and broken links
  • Follow the conventional commit format (feat(scope): description) for clear, searchable commit history
  • Contribute back by adding notebooks for patterns you discover—the Cookbook thrives on community contributions