The AI agent patterns cheat sheet: which pattern to reach for, and when to skip it
The short version
Most AI agents are built from the same handful of patterns. Anthropic worked with dozens of teams building agents and found that the most successful ones use simple, composable patterns instead of complex frameworks. Frameworks add layers that hide the prompts and responses, which makes them harder to debug.
So start with one model call and a good prompt. When it fails, find the failure in a row below and add only that row's pattern. This sheet has all six rows from the reel, a seventh row for safety, when to use and when to skip each pattern, and a prompt that picks the right ones for your app.
| Row |
The problem |
Reach for |
| 1 |
One call isn't enough |
Prompt chaining · routing · parallel calls |
| 2 |
It needs to act |
Tool calling · MCP · computer use |
| 3 |
The task is big |
Planner-executor · orchestrator-workers · subagents |
| 4 |
The output is weak |
Reflection · evaluator-optimizer · LLM-as-judge |
| 5 |
It keeps forgetting |
RAG · context compaction · memory files (CLAUDE.md) |
| 6 |
It costs too much |
Prompt caching · model routing |
| 7 |
It can do damage |
Human approval · sandboxes and permission gates |
Sources: Anthropic, Building effective agents (19 Dec 2024) · Claude docs: prompt caching
Copy these prompts
1. Pick the right patterns for your app
I'm building an AI feature. Here is what it does: <describe the task, the inputs, and what a good result looks like>.
Using these agent patterns (prompt chaining, routing, parallel calls, tool use, MCP, computer use, planner-executor,
orchestrator + subagents, reflection, evaluator-optimizer, LLM as judge, RAG, compaction, memory files, prompt caching,
model routing, human approval, sandboxes):
1. Tell me if a single model call is enough. If it is, stop there.
2. Otherwise pick the fewest patterns that solve it, one line each on why.
3. Say which pattern I should NOT use yet, and what would make me need it.
4. Sketch the flow as numbered steps I can build with the model API directly, no framework.
5. List the one thing that can do damage and the guard for it.
2. Map a failure to a row
Here is a failing run of my AI feature: <paste the input, the output, and what you expected>.
Which of these is the real problem: the task needs more than one call, it needs to act, the task is too big,
the output quality is weak, it forgets context, or it costs too much? Name the one row, the one pattern from
that row I should add, and the smallest change that tests whether it fixes this run.
Row 1: one call isn't enough
| Pattern |
What it is |
Use it when |
Skip it when |
| Prompt chaining |
Each call works on the last one's output |
The task splits into fixed steps (outline, draft, polish) |
One good prompt already does it |
| Routing |
Classify the input, send it to the right prompt or model |
Inputs fall into clear types (refund, bug, question) |
Every input needs the same handling |
| Parallel calls |
Sectioning (independent parts at once) or voting (same task several times) |
Parts don't depend on each other, or you want a second opinion |
Steps depend on each other |
Row 2: it needs to act
| Pattern |
What it is |
Use it when |
Skip it when |
| Tool calling |
The model calls your functions |
It needs live data or has to do something (search, send, write) |
It only needs to write text |
| MCP |
Plug a tool in once, use it from any MCP client |
You want the same tools in Claude Code, Claude Desktop and your app |
One tool in one app |
| Computer use |
The model drives a screen: clicks, types, reads screenshots |
The app has no API, only a UI |
There's an API or an MCP server for it |
Row 3: the task is big
| Pattern |
What it is |
Use it when |
Skip it when |
| Planner-executor |
One call writes the plan, the next calls carry out each step |
The steps can be known before you start |
The plan changes as it learns |
| Orchestrator-workers |
A lead model splits the job, hands pieces to workers, merges the results |
You can't know the subtasks up front (a change across many files) |
The steps are fixed: use chaining |
| Subagents |
Workers that each start with a fresh context window |
Each piece needs lots of reading the lead doesn't need to keep |
The pieces are small |
Row 4: the output is weak
| Pattern |
What it is |
Use it when |
Skip it when |
| Reflection |
The model critiques its own draft, then rewrites it |
A cheap first fix for sloppy answers |
It keeps approving its own mistakes |
| Evaluator-optimizer |
One model writes, a second grades it and sends it back until it passes |
You can write down what "good" means |
There's no clear bar to grade against |
| LLM-as-judge |
A model scores outputs against a rubric |
Checking lots of outputs at scale |
A simple test or regex can check it |
Row 5: it keeps forgetting
| Pattern |
What it is |
Use it when |
Skip it when |
| RAG |
Fetch the right docs into the prompt |
The answer lives in your docs or data |
It all fits in the prompt already |
| Context compaction |
Summarise old turns so a long session keeps going |
Long chats or coding sessions fill the window |
Short tasks |
| Memory files (CLAUDE.md) |
Standing rules the agent reads every session |
You keep repeating the same instructions |
One-off tasks |
Row 6: it costs too much
| Pattern |
What it is |
Use it when |
Skip it when |
| Prompt caching |
Reuse a long prompt prefix; cache reads cost 0.1x the input price or less |
The same long system prompt or docs go into every call |
Every prompt is different |
| Model routing |
Easy calls go to a small model, hard ones to a big one |
Most calls are simple (yes/no, classify, extract) |
Every call is hard |
Row 7 (bonus): it can do damage
| Pattern |
What it is |
Use it when |
Skip it when |
| Human approval |
A person approves anything risky: pay, delete, send, deploy |
The action is hard to undo |
Read-only work |
| Sandboxes and permission gates |
Run in a container, allow-list commands and paths |
It runs code or shell commands |
It never touches your system |
If you are building your first agent
- Start with one call and a good prompt. Measure where it fails.
- Each failure maps to a row: it forgets, go to row 5; too slow or costly, row 6; wrong answers, row 4.
- Add one pattern at a time, and keep the prompts visible so you can debug them.
- Anything that spends money, deletes or sends goes behind a human approval.
Run this on your codebase
Read this codebase and find every place it calls an AI model. For each one, tell me which agent pattern it
already uses (single call, chaining, routing, parallel, tools, MCP, orchestrator, reflection, evaluator, RAG,
compaction, memory file, caching, model routing, human approval, sandbox). Then flag the calls that would
benefit from one more pattern, name the pattern, and say in one sentence why. Flag any call that can spend
money, delete or send without a human approval.