Cookbook

Claude Cookbook

Practical guides and examples for using Claude effectively

Programmatic tool calling (PTC)Reduce latency and token consumption by letting Claude write code that calls tools programmatically in the code execution environment.

Tool search with embeddingsScale Claude applications to thousands of tools using semantic embeddings for dynamic tool discovery.

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

Giving Claude a crop tool for better image analysisGive Claude a crop tool to zoom into image regions for detailed analysis of charts, documents, and diagrams.

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

Introduction to Claude SkillsCreate documents, analyze data, automate workflows with Claude's Excel, PowerPoint, PDF skills.

All Cookbooks

Reproduce Claude's agentic search benchmark scores in the Messages APIJun 2026•EvalsToolsBuild a Messages API harness that reproduces published DeepSearchQA and BrowseComp scores, using programmatic tool calling, server-side compaction, and task budgets.

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

Mengting Li

Classifier fallback and billing for Claude Fable 5Jun 2026•ResponsesSafeguardsBillingDetect 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.

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.

Alexander Bricken

Mahesh Murag

Mikaela Grace

Async multi-agent orchestrationJun 2026•Agent PatternsTwo 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.

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.

Paul Chen

Hosting your agentMay 2026•Claude Agent SDKDeploy 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.

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.

Kevin Tang

Anav Sharma

Multiagent: coordinate a specialist teamMay 2026•Claude Managed AgentsToolsHeterogeneous 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. Covers the multiagent field, the thread_created / thread_message_received event types, and per-role tool scoping.

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. Covers the multiagent field, the thread_created / thread_message_received event types, and per-role tool scoping.

Mark Nowicki

Outcomes: agents that verify their own workMay 2026•Claude Managed AgentsEvalsBuild 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 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.

Mark Nowicki

Gagan Bhat

Build agents that remember your usersApr 2026•Claude Managed AgentsToolsGive your Claude Managed Agents a Memory store so they learn and remember your users' preferences across multiple interactions.

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

Gagan Bhat

The vulnerability detection agentApr 2026•Claude Agent SDKCybersecurityBuild 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 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.

Eugene Yan

Build an SRE incident response agent with Claude Managed AgentsApr 2026•Claude Managed AgentsObservabilityWire 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.

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.

Gagan Bhat

Build a data analyst agent with Claude Managed AgentsApr 2026•Claude Managed AgentsToolsBuild an analyst that turns a CSV into a narrative HTML report with interactive charts, using a sandboxed environment and file mounting.

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

Charmaine Lee

Jess Yan

Build a Slack data analyst bot with Claude Managed AgentsApr 2026•Claude Managed AgentsIntegrationsMention the bot with a CSV to get an analysis report in-thread, with multi-turn follow-ups on the same session.

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

Charmaine Lee

Managed Agents tutorial: iterate on a failing test suiteApr 2026•Claude Managed AgentsToolsEntry-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.

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.

Paul Yang

Managed Agents tutorial: production setupApr 2026•Claude Managed AgentsIntegrationsEnd-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, and the resource lifecycle CRUD verbs.

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, and the resource lifecycle CRUD verbs.

Paul Yang

Managed Agents tutorial: prompt versioning and rollbackApr 2026•Claude Managed AgentsEvalsServer-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.

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.

Mark Nowicki

Threat intelligence enrichment agentApr 2026•ToolsAgent PatternsCybersecurityBuild 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.

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.

Jannet Park

Building a session browserMar 2026•Claude Agent SDKAgent PatternsList, read, rename, tag, and fork Agent SDK sessions on disk to build a conversation history sidebar without writing a transcript parser.

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

Qing Wang

Knowledge graph construction with ClaudeMar 2026•RAG & RetrievalToolsBuild knowledge graphs from unstructured text using Claude for entity extraction, relation mining, deduplication, and multi-hop graph querying.

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

Anthropic

Context engineering: memory, compaction, and tool clearingMar 2026•ToolsAgent PatternsCompare context engineering strategies for long-running agents and learn when each applies, what it costs, and how they compose.

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

Isabella He

Migrating from the OpenAI Agents SDKMar 2026•Claude Agent SDKAgent PatternsPort an OpenAI Agents SDK app to the Claude Agent SDK, mapping each primitive (tools, guardrails, sessions, handoffs) through a single expense-approval agent example.

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.

Preston Tuggle

The site reliability agentFeb 2026•Claude Agent SDKAgent PatternsBuild an incident response agent with read-write MCP tools for autonomous diagnosis, remediation, and post-mortem documentation.

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

Ben Lehrburger

Isabella He

Session memory compactionJan 2026•Agent PatternsResponsesManage long-running Claude conversations with instant session memory compaction using background threading and prompt caching.

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

Joe Shamon

Programmatic tool calling (PTC)Nov 2025•ToolsReduce latency and token consumption by letting Claude write code that calls tools programmatically in the code execution environment.

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

Pedram Navid

Tool search with embeddingsNov 2025•ToolsRAG & RetrievalScale Claude applications to thousands of tools using semantic embeddings for dynamic tool discovery.

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

Henry Keetay

Automatic context compactionNov 2025•ToolsAgent PatternsManage context limits in long-running agentic workflows by automatically compressing conversation history.

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

Pedram Navid

Low latency voice assistant with ElevenLabsNov 2025•IntegrationsBuild a low-latency voice assistant using ElevenLabs for speech-to-text and text-to-speech combined with Claude.

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

Adriaan Engelbrecht

Giving Claude a crop tool for better image analysisNov 2025•MultimodalToolsGive Claude a crop tool to zoom into image regions for detailed analysis of charts, documents, and diagrams.

Give Claude a crop tool to zoom into image regions for detailed analysis of charts, documents, and diagrams.

Nadine Yasser

Prompting for frontend aestheticsOct 2025•ResponsesSkillsGuide to prompting Claude for distinctive, polished frontend designs avoiding generic aesthetics.

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

Prithvi Rajasekaran

Claude Skills for financial applicationsOct 2025•SkillsBuild financial dashboards and portfolio analytics using Claude's Excel, PowerPoint, PDF skills.

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

Alex Notov

Building custom Skills for ClaudeOct 2025•SkillsCreate, deploy, and manage custom skills extending Claude with specialized organizational workflows.

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

Alex Notov

Introduction to Claude SkillsOct 2025•SkillsCreate documents, analyze data, automate workflows with Claude's Excel, PowerPoint, PDF skills.

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

Alex Notov

The one-liner research agentSep 2025•Claude Agent SDKAgent PatternsBuild a research agent using Claude Code SDK with WebSearch for autonomous research.

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

Rodrigo Olivares

Jiri De Jonghe

The chief of staff agentSep 2025•Claude Agent SDKAgent PatternsBuild multi-agent systems with subagents, hooks, output styles, and plan mode features.

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

Rodrigo Olivares

Jiri De Jonghe

The observability agentSep 2025•Claude Agent SDKAgent PatternsConnect agents to external systems via MCP servers for GitHub monitoring and CI workflows.

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

Rodrigo Olivares

Jiri De Jonghe

Tool evaluationSep 2025•EvalsRun parallel agent evaluations on tools independently from evaluation task files.

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

Anthropic

Usage & cost Admin API cookbookAug 2025•ObservabilityProgrammatically access and analyze your Claude API usage and cost data via Admin API.

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

Anthropic

Memory & context management with Claude Sonnet 4.6May 2025•ToolsAgent PatternsBuild AI agents with persistent memory using Claude's memory tool and context editing.

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

Alex Notov

Speculative prompt cachingMay 2025•ResponsesReduce time-to-first-token by warming cache speculatively while users formulate their queries.

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

Anthropic

Parallel tool calls on Claude 3.7 SonnetMar 2025•ToolsEnable parallel tool calls on Claude 3.7 Sonnet using batch tool meta-pattern workaround.

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

Anthropic

Extended thinkingFeb 2025•ThinkingUse Claude's extended thinking for transparent step-by-step reasoning with budget management.

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

Alex Albert

Extended thinking with tool useFeb 2025•ThinkingToolsCombine extended thinking with tools for transparent reasoning during multi-step workflows.

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

Alex Albert

Basic workflowsDec 2024•Agent PatternsThree simple multi-LLM workflow patterns trading cost or latency for improved performance.

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

Anthropic

Evaluator optimizerDec 2024•Agent PatternsEvalsWorkflow pattern using one LLM for generation and another for evaluation feedback loop.

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

Anthropic

Orchestrator workersDec 2024•Agent PatternsCentral LLM dynamically delegates tasks to worker LLMs and synthesizes their combined results.

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

Anthropic

Batch processing with Message Batches APIOct 2024•ResponsesProcess large volumes of Claude requests asynchronously with 50% cost reduction using batches.

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

Alex Albert

Text to SQL with ClaudeSep 2024•RAG & RetrievalConvert natural language queries to SQL using RAG, chain-of-thought, and self-improvement techniques.

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

Mahesh Murag

Enhancing RAG with contextual retrievalSep 2024•RAG & RetrievalImprove RAG accuracy by adding context to chunks before embedding with prompt caching.

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

Anthropic

Finetuning Claude 3 Haiku on BedrockAug 2024•Fine-TuningStep-by-step guide to finetuning Claude 3 Haiku on Amazon Bedrock for custom tasks.

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

David Hershey

Generate synthetic test data for your prompt templateAug 2024•EvalsGenerate synthetic test cases to evaluate and improve your Claude prompt templates effectively.

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

Anthropic

Prompt caching through the Claude APIAug 2024•ResponsesCache and reuse prompt context for cost savings and faster responses with detailed instructions.

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

Alex Albert

Summarization with ClaudeAug 2024•RAG & RetrievalResponsesComprehensive guide to summarizing legal documents with evaluation and advanced techniques.

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

Alexander Bricken

Retrieval augmented generationJul 2024•RAG & RetrievalBuild and optimize RAG systems with Claude using summary indexing and reranking techniques.

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

Anthropic

Classification with ClaudeMay 2024•RAG & RetrievalBuild classification systems with Claude using RAG and chain-of-thought for insurance tickets.

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

Garvan Doyle

Tool choiceMay 2024•ToolsControl how Claude selects tools using tool_choice parameter for forced or auto selection.

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

Alex Albert

Using vision with toolsMay 2024•MultimodalToolsCombine Claude's vision with tools to extract structured data from images like nutrition labels.

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

Alex Albert

Sampling responses from Claude beyond the max tokens limitMay 2024•ResponsesGenerate longer responses beyond max_tokens limit using prefill technique with message continuation.

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

Anthropic

Best practices for using vision with ClaudeMay 2024•MultimodalTips and techniques for optimal image processing performance with Claude's vision capabilities.

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

Alex Albert

Note-saving tool with Pydantic and Anthropic tool useApr 2024•ToolsCreate validated tools using Pydantic models for type-safe Claude tool use interactions.

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

Alex Albert

Transcribe an audio file with Deepgram & use Anthropic to prepare interview questions!Apr 2024•IntegrationsMultimodalTranscribe audio with Deepgram and generate interview questions using Claude for preparation.

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

john-vajda

Using the Wolfram Alpha LLM API as a tool with ClaudeApr 2024•IntegrationsToolsIntegrate Wolfram Alpha LLM API as Claude tool for computational queries and answers.

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

Alex Albert

Using a calculator tool with ClaudeApr 2024•ToolsProvide Claude with calculator tool for arithmetic operations and mathematical problem solving.

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

Alex Albert

Creating a customer service agent with client-side toolsApr 2024•ToolsAgent PatternsBuild customer service chatbot with Claude using tools for customer lookup and order management.

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

Alex Albert

Extracting structured JSON using Claude and tool useApr 2024•ResponsesToolsExtract structured JSON data from various inputs using Claude's tool use capabilities.

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

Alex Albert

MetapromptMar 2024•ResponsesPrompt engineering tool that generates starting prompts for your tasks to solve blank-page problem.

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

Anthropic

CitationsMar 2024•ResponsesRAG & RetrievalEnable Claude to provide detailed source citations when answering document-based questions for verification.

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

Anthropic

Claude 3 RAG agents with LangChain v1Mar 2024•IntegrationsRAG & RetrievalAgent PatternsBuild RAG agents with Claude 3 using LangChain v1's updated agent framework patterns.

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

james-briggs

Summarizing web page content with Claude 3 HaikuMar 2024•RAG & RetrievalFetch and summarize web page content using Claude 3 Haiku via URL extraction.

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

Alex Albert

Using Haiku as a sub-agentMar 2024•Agent PatternsAnalyze financial reports using Haiku sub-agents for extraction and Opus for synthesis.

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

Alex Albert

Multi-modalMar 2024•IntegrationsMultimodalUse LlamaIndex's Anthropic MultiModal LLM abstraction for image understanding and reasoning.

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

Ravi Theja

How to build a RAG system using Claude 3 and MongoDBMar 2024•IntegrationsRAG & RetrievalBuild chatbot RAG system with Claude and MongoDB using tech news as knowledge base.

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

Richmond Alake

Building evalsMar 2024•EvalsBuild robust evaluation systems to measure and improve Claude's performance on key metrics.

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

Alex Albert

Building a moderation filter with ClaudeMar 2024•ResponsesBuild customizable content moderation filters by defining rules and categories in prompts.

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

Alex Albert

Prompting Claude for "JSON mode"Mar 2024•ResponsesGet reliable JSON output from Claude using effective prompting techniques without constrained sampling.

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

Alex Albert

How to make SQL queries with ClaudeMar 2024•RAG & RetrievalGenerate SQL queries from natural language questions using Claude with database schema context.

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

Alex Albert

Getting started - how to pass images into ClaudeMar 2024•MultimodalTutorial on passing images to Claude 3 API for vision-based text analysis.

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

Alex Albert

How to transcribe documents with ClaudeMar 2024•MultimodalExtract and structure unstructured text from images and PDFs using Claude 3's vision.

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

Alex Albert

Working with charts, graphs, and slide decksMar 2024•MultimodalExtract insights from charts, graphs, and presentations using Claude's vision analysis capabilities.

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

Alex Albert

Multi-document agentsMar 2024•IntegrationsRAG & RetrievalAgent PatternsBuild RAG for large document collections using DocumentAgents with ReAct Agent pattern.

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

Ravi Theja

ReAct agentMar 2024•IntegrationsAgent PatternsToolsCreate ReAct agents with LlamaIndex for tool-based reasoning and action workflows.

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

Ravi Theja

RAG pipeline with LlamaIndexMar 2024•IntegrationsRAG & RetrievalBuild basic RAG pipeline with LlamaIndex for document retrieval and question answering.

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

Ravi Theja

RouterQuery engineMar 2024•IntegrationsRAG & RetrievalRoute queries to different indices using LlamaIndex RouterQueryEngine for multi-document search.

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

Ravi Theja

SubQuestionQueryEngineMar 2024•IntegrationsRAG & RetrievalDecompose complex queries into sub-questions across multiple documents using LlamaIndex engine.

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

Ravi Theja

Retrieval-augmented generation using PineconeFeb 2024•IntegrationsRAG & RetrievalConnect Claude with Pinecone vector database for retrieval-augmented generation and semantic search.

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

Alex Albert

"Uploading" PDFs to Claude via the APIAug 2023•RAG & RetrievalProcess and summarize PDF documents using Claude API with text extraction and encoding.

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

Anthropic

Iteratively searching Wikipedia with ClaudeAug 2023•IntegrationsLegacy notebook showing iterative Wikipedia searches with Claude 2 for research workflows.

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

Anthropic

Contributions welcome

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

Contribution guide