Agent SDK Patterns
Production patterns for building AI agents with the Claude Agent SDK: the loop, subagents, permissions, context management, MCP, and hooks — plus when to use the SDK vs the raw API.
Last updated
Agent SDK: Production-Ready Patterns
The raw Messages API gives you one call. Real agents need the loop, tool orchestration, subagents, permissions, context management, and hooks around it. The Claude Agent SDK is that harness — when to reach for it, and the patterns that matter.
Everything so far — the loop, tool use, memory, delegation — you can hand-build on the Messages API, and understanding how is the point of this guide. But rebuilding the harness for every project is wasted motion. The Claude Agent SDK (the engine extracted from Claude Code) packages the battle-tested pieces: the agent loop, tool execution, subagents, permission gating, context compaction, MCP connectivity, and lifecycle hooks. The FDE skill isn’t “can you use the SDK” — it’s knowing which layer to build at, and what production concerns the harness has to solve no matter who writes it.
Related
More in LLM & Agentic
LLM Lifecycle
PreviewComplete lifecycle of large language models from pre-training through fine-tuning, RLHF, and deployment — with architecture diagrams and production considerations.
How LLMs Call Tools
PreviewHow LLMs use function calling and tool use — the mechanics behind tool-calling agents, from prompt engineering to structured output.
When to Fine-Tune: The Decision Framework
PreviewShould you fine-tune at all? A structured decision framework for prompt engineering vs RAG vs fine-tuning.
LoRA, QLoRA & PEFT Methods
PreviewHow LoRA works inside transformer layers, QLoRA for memory-efficient training, and the full PEFT method comparison with code examples.
Get full access to all 87+ sections with code examples, diagrams, and interactive animations.
Unlock Premium