Source: raw/claude-cookbooks-main/

The official Anthropic cookbook repository (github.com/anthropics/anthropic-cookbook) containing Jupyter notebooks and Python examples for building with the Claude API. This article catalogs the cookbooks as a CCA-F study resource, organizing them by exam domain relevance. Each notebook provides hands-on code you can run to internalize the patterns tested on the exam.

Repository Overview

  • Language: Python (Jupyter notebooks)
  • License: MIT
  • Key directories: tool_use/, capabilities/, misc/, multimodal/, patterns/agents/, claude_agent_sdk/, managed_agents/, skills/, extended_thinking/
  • Prerequisites: Anthropic API key, Python 3.10+, uv for dependency management
  • Setup: uv sync --all-extras, then cp .env.example .env and add your ANTHROPIC_API_KEY

Cookbooks by Exam Domain

Domain 1: Agentic Architecture & Orchestration (27%)

These notebooks demonstrate the agentic loop lifecycle, coordinator-subagent patterns, and multi-agent orchestration:

NotebookPathWhat it teaches
Customer Service Agenttool_use/customer_service_agent.ipynbFull agentic loop: tool calls, stop_reason checking, conversation management. Directly maps to Task 1.1
Orchestrator Workerspatterns/agents/orchestrator_workers.ipynbCoordinator-subagent pattern with parallel workers. Maps to Tasks 1.2, 1.3
Basic Workflowspatterns/agents/basic_workflows.ipynbPrompt chaining, routing, parallelization patterns. Maps to Task 1.6
Evaluator Optimizerpatterns/agents/evaluator_optimizer.ipynbIterative refinement loops where evaluator guides optimizer. Maps to Task 1.6
Sub-Agentsmultimodal/using_sub_agents.ipynbSpawning sub-agents for parallel processing. Maps to Task 1.3
One-Liner Research Agentclaude_agent_sdk/00_The_one_liner_research_agent.ipynbMinimal Agent SDK setup. Maps to Tasks 1.1, 1.3
Chief of Staff Agentclaude_agent_sdk/01_The_chief_of_staff_agent.ipynbMulti-agent delegation with coordinator. Maps to Tasks 1.2, 1.3
Session Browserclaude_agent_sdk/05_Building_a_session_browser.ipynbSession management and state inspection. Maps to Task 1.7

Managed Agents cookbooks (advanced agentic patterns):

  • CMA_orchestrate_issue_to_pr.ipynb — end-to-end orchestration from GitHub issue to PR
  • CMA_iterate_fix_failing_tests.ipynb — iterative test-fixing loops
  • CMA_gate_human_in_the_loop.ipynb — human-in-the-loop gating patterns
  • CMA_operate_in_production.ipynb — production operation patterns
  • CMA_explore_unfamiliar_codebase.ipynb — codebase exploration strategies

Domain 2: Tool Design & MCP Integration (18%)

These notebooks cover tool definition, structured errors, tool choice configuration, and tool search patterns:

NotebookPathWhat it teaches
Calculator Tooltool_use/calculator_tool.ipynbBasic tool definition with JSON schema. Maps to Task 2.1
Parallel Toolstool_use/parallel_tools.ipynbParallel tool execution patterns. Maps to Task 2.3
Tool Choicetool_use/tool_choice.ipynbauto, any, and forced tool selection. Maps to Task 2.3
Tool Search (Embeddings)tool_use/tool_search_with_embeddings.ipynbSemantic tool search for large tool sets. Maps to Task 2.3
Tool Search (Alternate)tool_use/tool_search_alternate_approaches.ipynbAlternative approaches to tool discovery. Maps to Task 2.3
Programmatic Tool Callingtool_use/programmatic_tool_calling_ptc.ipynbProgrammatic (non-LLM) tool execution. Maps to Tasks 2.1, 2.3
Context Engineering Toolstool_use/context_engineering/context_engineering_tools.ipynbContext-aware tool design. Maps to Tasks 2.1, 2.4
Memory Cookbooktool_use/memory_cookbook.ipynbPersistent memory tools. Maps to Task 2.4
Automatic Context Compactiontool_use/automatic-context-compaction.ipynbAutomatic context management. Maps to Tasks 2.4, 5.4
Tool Use with Pydantictool_use/tool_use_with_pydantic.ipynbSchema validation with Pydantic. Maps to Task 2.1
Tool Evaluationtool_evaluation/tool_evaluation.ipynbEvaluating tool use quality. Maps to Task 2.1
Threat Intel Agenttool_use/threat_intel_enrichment_agent.ipynbMulti-tool agent for security. Maps to Tasks 2.1, 2.3

Domain 3: Claude Code Configuration & Workflows (20%)

The cookbooks repo itself demonstrates Claude Code configuration patterns:

ResourcePathWhat it teaches
Root CLAUDE.mdCLAUDE.mdProject-level configuration with coding standards, model aliases, git workflow. Maps to Task 3.1
Slash Commands.claude/commands/Project-scoped commands (notebook-review, review-pr, link-review, model-check). Maps to Task 3.2
Skills.claude/skills/cookbook-audit/SKILL.mdSkill with style guide reference, demonstrating SKILL.md frontmatter. Maps to Task 3.2
Code Reviewer Agent.claude/agents/code-reviewer.mdAgent definition for automated code review. Maps to Task 3.6
Skills Notebooksskills/notebooks/01_skills_introduction.ipynbIntroduction to skills system. Maps to Task 3.2
Skills Custom Devskills/notebooks/03_skills_custom_development.ipynbBuilding custom skills. Maps to Task 3.2

Domain 4: Prompt Engineering & Structured Output (20%)

These notebooks demonstrate structured output, few-shot prompting, batch processing, and validation patterns:

NotebookPathWhat it teaches
Extracting Structured JSONtool_use/extracting_structured_json.ipynbJSON extraction via tool_use. Maps to Task 4.3
Enable JSON Modemisc/how_to_enable_json_mode.ipynbReliable JSON output. Maps to Task 4.3
Batch Processingmisc/batch_processing.ipynbMessage Batches API usage, custom_id correlation. Maps to Task 4.5
Building Evalsmisc/building_evals.ipynbAutomated evaluation patterns. Maps to Tasks 4.4, 4.6
Generate Test Casesmisc/generate_test_cases.ipynbTest case generation. Maps to Task 3.5
Moderation Filtermisc/building_moderation_filter.ipynbContent classification with structured output. Maps to Task 4.1
Using Citationsmisc/using_citations.ipynbCitation tracking in output. Maps to Task 5.6
Classification Guidecapabilities/classification/guide.ipynbClassification patterns with explicit criteria. Maps to Task 4.1
Summarization Guidecapabilities/summarization/guide.ipynbSummarization with structured output. Maps to Task 4.3
RAG Guidecapabilities/retrieval_augmented_generation/guide.ipynbRetrieval-augmented generation. Maps to Tasks 4.2, 5.1
Vision with Toolstool_use/vision_with_tools.ipynbMultimodal structured extraction. Maps to Task 4.3
Metapromptmisc/metaprompt.ipynbPrompt generation and refinement. Maps to Task 4.1

Domain 5: Context Management & Reliability (15%)

These notebooks address context window management, prompt caching, session memory, and long-document handling:

NotebookPathWhat it teaches
Prompt Cachingmisc/prompt_caching.ipynbCache-aware prompt design, cost reduction. Maps to Task 5.1
Speculative Cachingmisc/speculative_prompt_caching.ipynbAdvanced caching strategies. Maps to Task 5.1
Session Memory Compactionmisc/session_memory_compaction.ipynbCompacting long conversation history. Maps to Tasks 5.1, 5.4
Automatic Context Compactiontool_use/automatic-context-compaction.ipynbAutomated context management. Maps to Task 5.4
PDF Upload Summarizationmisc/pdf_upload_summarization.ipynbHandling long documents. Maps to Task 5.1
Sampling Past Max Tokensmisc/sampling_past_max_tokens.ipynbWorking beyond token limits. Maps to Task 5.1
Observability Agentclaude_agent_sdk/02_The_observability_agent.ipynbAgent monitoring and observability. Maps to Task 5.3
SRE Agentclaude_agent_sdk/03_The_site_reliability_agent.ipynbReliability patterns in practice. Maps to Task 5.3
Prompt Versioning & Rollbackmanaged_agents/CMA_prompt_versioning_and_rollback.ipynbManaging prompt versions for reliability. Maps to Task 5.3

Extended Thinking (Cross-Domain)

NotebookPathWhat it teaches
Extended Thinkingextended_thinking/extended_thinking.ipynbChain-of-thought reasoning patterns. Relevant to Tasks 4.1, 4.6
Extended Thinking + Toolsextended_thinking/extended_thinking_with_tool_use.ipynbCombining reasoning with tool use. Relevant to Tasks 1.1, 4.3

Work through the notebooks in this order to build knowledge progressively:

  1. Week 1 — Tool Foundations: calculator_tool tool_choice parallel_tools extracting_structured_json
  2. Week 2 — Agentic Patterns: customer_service_agent basic_workflows orchestrator_workers evaluator_optimizer
  3. Week 3 — Production Concerns: batch_processing prompt_caching session_memory_compaction building_evals
  4. Week 4 — Advanced Agents: Agent SDK notebooks (00-05) Managed Agents notebooks context_engineering_tools

Key Takeaways

  • The cookbooks repository provides runnable code for nearly every CCA-F task statement — use it as your hands-on lab
  • Domain 1 (Agentic Architecture) has the richest notebook coverage: the patterns/agents/, claude_agent_sdk/, and managed_agents/ directories together cover all 7 task statements
  • Domain 2 (Tool Design) is well covered by the tool_use/ directory — especially tool_choice.ipynb and programmatic_tool_calling_ptc.ipynb
  • Domain 3 (Claude Code Config) is best studied by examining the repo’s own .claude/ directory structure rather than running notebooks
  • The misc/batch_processing.ipynb notebook is essential for Task 4.5 (batch strategies) — one of the most concrete exam topics
  • Domain 5 (Context & Reliability) content is spread across misc/ (caching, compaction) and the Agent SDK (observability, SRE patterns)

Try It

  1. Clone the repo: git clone https://github.com/anthropics/anthropic-cookbook.git and set up your API key
  2. Run customer_service_agent.ipynb first — it is the single most exam-relevant notebook, covering the agentic loop, tool use, and conversation management in one example
  3. Modify the examples — after running each notebook, change something (add a tool, modify the schema, break something intentionally) to see what happens
  4. Build your own cookbook — create a notebook that combines patterns from at least 3 different cookbooks into one integrated system
  5. Use the cookbooks as flashcards — for each notebook, write down which exam task statement it maps to without looking at this article