Claude Cookbook

Recipes

Practical guides and examples for using Claude effectively

Reduce latency and token consumption by letting Claude write code that calls tools programmatically in the code execution environment.

Scale Claude applications to thousands of tools using semantic embeddings for dynamic tool discovery.

Manage context limits in long-running agentic workflows by automatically compressing conversation history.

Give Claude a zoom tool that crops a region and magnifies it for detailed analysis of charts, documents, and diagrams.

Guide to prompting Claude for distinctive, polished frontend designs avoiding generic aesthetics.

Create documents, analyze data, automate workflows with Claude's Excel, PowerPoint, PDF skills.

All cookbooks

Title
Advisor: let a working agent consult a stronger model mid-turn

Add an advisor entry to a Managed Agents roster so a mid-tier working model can consult a more capable model inside a turn, read each consultation off the event stream, price it from the advisor thread's usage, and handle the redacted delivery arm.

Budgets: cap what a session can spend

Set an enforced list-cost budget on a Managed Agents session, watch spend accumulate through session.usage events, catch the budget_reached pause, and raise, lower, or remove the cap with sessions.update.

Skills: pick up a repo's .claude/skills automatically

Mount a GitHub repository so its root .claude/skills directory is discovered at session start and injected into the agent, watch the read-then-follow protocol when a request matches a skill description, and learn the layout and lifecycle rules.

Data residency: pin an agent's inference geography

Pin a Managed Agents agent to US-region inference with model.inference_geo, confirm the pin on a session, work with the workspace allowed_inference_geos policy, and override the geography for a single session with agent_with_overrides.

Orchestrate subagents at scale with dynamic workflows

Trigger a dynamic workflow from the Agent SDK to fact-check a report against source documents with parallel verifier and skeptic subagents.

Multiagent: watch a curriculum team work in real time

Stream a coordinator and its subagents live with per-thread event deltas, seed the session with initial_events, set model effort per agent, and update agents without the version round trip.

Coordinator pattern: big models for planning, small models for execution

Two-model team economics via the multiagent coordinator config — a frontier coordinator plans and synthesizes while cheap search workers do the token-heavy web reading in parallel threads, compared against a rigor-matched solo-frontier control with real bills. Covers per-thread usage.list_cost metering, cost attribution, and a session budget as the fan-out guardrail.

Reproduce Claude's agentic search benchmark scores in the Messages API
Jun 2026

Build a Messages API harness that reproduces published DeepSearchQA and BrowseComp scores, using programmatic tool calling, server-side compaction, and task budgets.

Fraud Review Agent with MongoDB Atlas and Claude Managed Agents

Bring MongoDB Atlas to a Claude Managed Agent as its retrieval engine, graph store, and system of record — three credential-safe ways to connect, the four retrieval patterns (vector, full-text, reciprocal rank fusion, $graphLookup) as liftable building blocks, and a human-in-the-loop fraud-review agent that records decisions and an append-only audit trail in the same cluster.

Classifier fallback and billing for Claude Fable 5
Jun 2026

Detect safety classifier blocks on Fable 5 and fall back to Opus 4.8 with server-side or SDK-based client-side fallback, including streaming behavior and the new billing changes.

Async multi-agent orchestration
Jun 2026

Two async multi-agent patterns — a fixed N-agent team with peer messaging through a shared hub, and dynamically spawned async subagents — reduced to their bare messaging and lifecycle mechanics.

Hosting your agent
May 2026

Deploy the research agent from notebook 00 through three tiers of operational maturity (Docker, Modal, Kubernetes) with the same container image and HTTP interface at every tier.

Multiagent: coordinate a specialist team

Heterogeneous team via the multiagent coordinator config — a coordinator runs three specialists (web-search researcher, file-reading librarian, rules-based pricer) with scoped toolsets to assemble a sales proposal, plus an advisor entry the coordinator consults before writing. Covers the multiagent field, the thread_created / thread_message_received event types, and per-role tool scoping.

Outcomes: agents that verify their own work

Build a grade-and-revise loop with Outcomes: a writer drafts a cited research brief, a stateless grader fetches every URL and checks every quote against a rubric, and feedback drives revisions until the brief passes. Covers user.define_outcome, the span.outcome_evaluation_* events, and how to write a rubric the grader can act on.

Build agents that remember your users

Give your Claude Managed Agents a Memory store so they learn and remember your users' preferences across multiple interactions.

The vulnerability detection agent

Build a vulnerability-discovery agent with the Claude Agent SDK that threat-models a C target, hunts memory-safety bugs with built-in file tools, and triages findings into a structured report.

Build an SRE incident response agent with Claude Managed Agents

Wire Claude into your on-call flow: when an alert fires, the agent reads logs and runbooks, pinpoints the root cause, opens a fix PR, and waits for your approval before merging.

Build a data analyst agent with Claude Managed Agents

Build an analyst that turns a CSV into a narrative HTML report with interactive charts, using a sandboxed environment and file mounting.

Build a Slack data analyst bot with Claude Managed Agents

Mention the bot with a CSV to get an analysis report in-thread, with multi-turn follow-ups on the same session.

Managed Agents tutorial: iterate on a failing test suite

Entry-point tutorial for the Claude Managed Agents API. Walks through agent / environment / session creation, file mounts, and the streaming event loop by getting an agent to fix three planted bugs in a calc.py package.

Managed Agents tutorial: production setup

End-to-end production story for Managed Agents — vault-backed MCP credentials, the session.status_idled webhook pattern for human-in-the-loop without long-lived connections, the session.budget_reached webhook, inference_geo pinning for residency, and the resource lifecycle CRUD verbs.

Managed Agents tutorial: prompt versioning and rollback

Server-side prompt versioning — create v1, evaluate against a labelled test set, ship v2, detect a regression, roll back by pinning sessions to version 1. Covers agents.update, version pinning on sessions.create, and where the review gate moves when prompts are not code.

Threat intelligence enrichment agent

Build an agent that autonomously investigates IOCs by querying multiple threat intel sources, cross-referencing findings, mapping to MITRE ATT&CK, and producing structured reports for SIEM and SOAR integration.

Building a session browser

List, read, rename, tag, and fork Agent SDK sessions on disk to build a conversation history sidebar without writing a transcript parser.

Knowledge graph construction with Claude

Build knowledge graphs from unstructured text using Claude for entity extraction, relation mining, deduplication, and multi-hop graph querying.

Context engineering: memory, compaction, and tool clearing

Compare context engineering strategies for long-running agents and learn when each applies, what it costs, and how they compose.

Migrating from the OpenAI Agents SDK

Port an OpenAI Agents SDK app to the Claude Agent SDK, mapping each primitive (tools, guardrails, sessions, handoffs) through a single expense-approval agent example.

The site reliability agent

Build an incident response agent with read-write MCP tools for autonomous diagnosis, remediation, and post-mortem documentation.

Session memory compaction

Manage long-running Claude conversations with instant session memory compaction using background threading and prompt caching.

Programmatic tool calling (PTC)
Nov 2025

Reduce latency and token consumption by letting Claude write code that calls tools programmatically in the code execution environment.

Tool search with embeddings

Scale Claude applications to thousands of tools using semantic embeddings for dynamic tool discovery.

Automatic context compaction

Manage context limits in long-running agentic workflows by automatically compressing conversation history.

Low latency voice assistant with ElevenLabs
Nov 2025

Build a low-latency voice assistant using ElevenLabs for speech-to-text and text-to-speech combined with Claude.

Giving Claude a zoom tool for reading fine image detail
Nov 2025

Give Claude a zoom tool that crops a region and magnifies it for detailed analysis of charts, documents, and diagrams.

Prompting for frontend aesthetics
Oct 2025

Guide to prompting Claude for distinctive, polished frontend designs avoiding generic aesthetics.

Claude Skills for financial applications
Oct 2025

Build financial dashboards and portfolio analytics using Claude's Excel, PowerPoint, PDF skills.

Building custom Skills for Claude
Oct 2025

Create, deploy, and manage custom skills extending Claude with specialized organizational workflows.

Introduction to Claude Skills
Oct 2025

Create documents, analyze data, automate workflows with Claude's Excel, PowerPoint, PDF skills.

The one-liner research agent

Build a research agent using Claude Code SDK with WebSearch for autonomous research.

The chief of staff agent

Build multi-agent systems with subagents, hooks, output styles, and plan mode features.

The observability agent

Connect agents to external systems via MCP servers for GitHub monitoring and CI workflows.

Tool evaluation
Sep 2025

Run parallel agent evaluations on tools independently from evaluation task files.

Usage & cost Admin API cookbook
Aug 2025

Programmatically access and analyze your Claude API usage and cost data via Admin API.

Memory & context management with Claude Sonnet 4.6

Build AI agents with persistent memory using Claude's memory tool and context editing.

Speculative prompt caching
May 2025

Reduce time-to-first-token by warming cache speculatively while users formulate their queries.

Parallel tool calls on Claude 3.7 Sonnet
Mar 2025

Enable parallel tool calls on Claude 3.7 Sonnet using batch tool meta-pattern workaround.

Extended thinking
Feb 2025

Use Claude's extended thinking for transparent step-by-step reasoning with budget management.

Extended thinking with tool use
Feb 2025

Combine extended thinking with tools for transparent reasoning during multi-step workflows.

Basic workflows
Dec 2024

Three simple multi-LLM workflow patterns trading cost or latency for improved performance.

Evaluator optimizer

Workflow pattern using one LLM for generation and another for evaluation feedback loop.

Orchestrator workers
Dec 2024

Central LLM dynamically delegates tasks to worker LLMs and synthesizes their combined results.

Batch processing with Message Batches API
Oct 2024

Process large volumes of Claude requests asynchronously with 50% cost reduction using batches.

Text to SQL with Claude
Sep 2024

Convert natural language queries to SQL using RAG, chain-of-thought, and self-improvement techniques.

Enhancing RAG with contextual retrieval
Sep 2024

Improve RAG accuracy by adding context to chunks before embedding with prompt caching.

Finetuning Claude 3 Haiku on Bedrock
Aug 2024

Step-by-step guide to finetuning Claude 3 Haiku on Amazon Bedrock for custom tasks.

Generate synthetic test data for your prompt template
Aug 2024

Generate synthetic test cases to evaluate and improve your Claude prompt templates effectively.

Prompt caching through the Claude API
Aug 2024

Cache and reuse prompt context for cost savings and faster responses with detailed instructions.

Summarization with Claude

Comprehensive guide to summarizing legal documents with evaluation and advanced techniques.

Retrieval augmented generation
Jul 2024

Build and optimize RAG systems with Claude using summary indexing and reranking techniques.

Classification with Claude
May 2024

Build classification systems with Claude using RAG and chain-of-thought for insurance tickets.

Tool choice
May 2024

Control how Claude selects tools using tool_choice parameter for forced or auto selection.

Using vision with tools
May 2024

Combine Claude's vision with tools to extract structured data from images like nutrition labels.

Sampling responses from Claude beyond the max tokens limit
May 2024

Generate longer responses beyond max_tokens limit using prefill technique with message continuation.

Best practices for using vision with Claude
May 2024

Tips and techniques for optimal image processing performance with Claude's vision capabilities.

Note-saving tool with Pydantic and Anthropic tool use
Apr 2024

Create validated tools using Pydantic models for type-safe Claude tool use interactions.

Transcribe an audio file with Deepgram & use Anthropic to prepare interview questions!

Transcribe audio with Deepgram and generate interview questions using Claude for preparation.

Using the Wolfram Alpha LLM API as a tool with Claude

Integrate Wolfram Alpha LLM API as Claude tool for computational queries and answers.

Using a calculator tool with Claude
Apr 2024

Provide Claude with calculator tool for arithmetic operations and mathematical problem solving.

Creating a customer service agent with client-side tools

Build customer service chatbot with Claude using tools for customer lookup and order management.

Extracting structured JSON using Claude and tool use
Apr 2024

Extract structured JSON data from various inputs using Claude's tool use capabilities.

Metaprompt
Mar 2024

Prompt engineering tool that generates starting prompts for your tasks to solve blank-page problem.

Citations

Enable Claude to provide detailed source citations when answering document-based questions for verification.

Claude 3 RAG agents with LangChain v1

Build RAG agents with Claude 3 using LangChain v1's updated agent framework patterns.

Summarizing web page content with Claude 3 Haiku
Mar 2024

Fetch and summarize web page content using Claude 3 Haiku via URL extraction.

Using Haiku as a sub-agent
Mar 2024

Analyze financial reports using Haiku sub-agents for extraction and Opus for synthesis.

Multi-modal

Use LlamaIndex's Anthropic MultiModal LLM abstraction for image understanding and reasoning.

How to build a RAG system using Claude 3 and MongoDB

Build chatbot RAG system with Claude and MongoDB using tech news as knowledge base.

Building evals
Mar 2024

Build robust evaluation systems to measure and improve Claude's performance on key metrics.

Building a moderation filter with Claude
Mar 2024

Build customizable content moderation filters by defining rules and categories in prompts.

Prompting Claude for "JSON mode"
Mar 2024

Get reliable JSON output from Claude using effective prompting techniques without constrained sampling.

How to make SQL queries with Claude
Mar 2024

Generate SQL queries from natural language questions using Claude with database schema context.

Getting started - how to pass images into Claude
Mar 2024

Tutorial on passing images to Claude 3 API for vision-based text analysis.

How to transcribe documents with Claude
Mar 2024

Extract and structure unstructured text from images and PDFs using Claude 3's vision.

Working with charts, graphs, and slide decks
Mar 2024

Extract insights from charts, graphs, and presentations using Claude's vision analysis capabilities.

Multi-document agents

Build RAG for large document collections using DocumentAgents with ReAct Agent pattern.

ReAct agent

Create ReAct agents with LlamaIndex for tool-based reasoning and action workflows.

RAG pipeline with LlamaIndex

Build basic RAG pipeline with LlamaIndex for document retrieval and question answering.

RouterQuery engine

Route queries to different indices using LlamaIndex RouterQueryEngine for multi-document search.

SubQuestionQueryEngine

Decompose complex queries into sub-questions across multiple documents using LlamaIndex engine.

Retrieval-augmented generation using Pinecone

Connect Claude with Pinecone vector database for retrieval-augmented generation and semantic search.

"Uploading" PDFs to Claude via the API
Aug 2023

Process and summarize PDF documents using Claude API with text extraction and encoding.

Iteratively searching Wikipedia with Claude
Aug 2023

Legacy notebook showing iterative Wikipedia searches with Claude 2 for research workflows.

Contributions welcome

Have an idea for a cookbook? We welcome community contributions.

Contribution guide