Claude Cookbook
TL;DR Highlight
Anthropic published a cookbook of recipes for agents, tool calling, RAG, and caching with Claude
Who Should Read
Backend developers building agents or RAG on the Claude API who want official example code to reference
Core Mechanics
- Claude Cookbook is a collection of examples
- It gathers practical guides and examples for using Claude, grouped by category.
- Categories include Agent Patterns, Tools, RAG & Retrieval, Evals, Observability, Multimodal, Skills, Thinking, and Fine-Tuning.
- Recipes for tool-calling efficiency
- Programmatic tool calling (PTC) has Claude write code that calls tools in a code execution environment, cutting latency and token use.
- Tool search with embeddings uses semantic embeddings to discover tools dynamically, scaling to thousands of tools.
- Recipes for long-context management
- Automatic context compaction compresses conversation history for long-running agents.
- Session memory compaction compacts instantly using background threading and prompt caching.
- Recipes for cost and speed
- The Message Batches API recipe claims a 50% cost reduction via asynchronous processing.
- Speculative prompt caching warms the cache while users type to reduce time-to-first-token.
Community Reactions
- Opinion that official guides are pointless
- Commenters said most of this is trivial, will be baked into harnesses, and agent workflow material feels like theatre.
- Another view was that such recipes get absorbed into the next model version.
- Criticism of the frontend aesthetics examples
- Commenters said the before and after images are both bland, or just bland with gradients.
- Others pointed out even basic UI like table spacing is off.
- Maintenance worries and alternatives
- One commenter said Copilot and OpenAI cookbooks started with many examples and later went unmaintained.
- The OpenAI Cookbook was suggested as another resource.
- Opinion that the best CLAUDE.md is none
- One commenter argued tech stack and test style should be obvious from the code, so CLAUDE.md isn't needed.
How to Apply
- Find one pattern you use in the Cookbook
- If your agent has many tools or high token use, read the PTC and Tool search with embeddings recipes today.
- Note what differs from your current implementation.
- Add context compaction to long agent sessions
- Try the Automatic context compaction recipe on an agent with long conversations.
- Compare token counts and answer quality before and after.
- Apply caching and batching to repeated calls
- Move non-realtime bulk requests to the Message Batches API.
- For latency-sensitive paths, measure time-to-first-token with the Speculative prompt caching recipe.
Try It
# Paste into Claude (simple prompt for choosing a Cookbook recipe)
I run a service on the Claude API.
{{service description}}
My current problem is:
{{latency, cost, context overflow, too many tools, etc.}}
Prioritize which of these Claude Cookbook recipes to apply first.
- Programmatic tool calling
- Tool search with embeddings
- Automatic context compaction
- Speculative prompt caching
- Batch processing with Message Batches API
- Contextual retrieval
For each recipe, give one line on why and a 30-minute experiment.
Next: open the notebook for the top recipe and compare it against your code.Terminology
Related Papers
Same Simulation, Different Evidence: Where Retrieved Tool Output Costs LLM Agents Accuracy
Saving long tool output to files cut GPT-5.1 accuracy by 11.3 points; naming the authoritative file restored it.
Fake News, Real Crashes: Information Injection Attacks on LLM Financial Trading Agents
Fake headlines hijacked LLM trading agents 62% of the time versus 14% for prompt injection.
Harness Engineering 101: The LLM is the brain, the harness is the body
An agent is a loop managing a JSON array; 16 chapters build one from scratch
Harness2 by Google Research – Recursive Agent Harnessing
Recursively refining the harness with fixed model weights raised benchmark scores by up to 11.8 points.
Ousted Savannah police officer gave ICE agent husband access to Flock system
A police officer shared her Flock login with her ICE-agent husband; an audit found 983 searches and she was fired
Tmux and Claude Code: Sessions, Send-Keys, and the Ceiling
Running Claude Code agents in tmux works well, but limits appear around four agents.