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
After this section you can
- Choose between the Agent SDK, the Tool Runner or a manual loop, and Managed Agents for a given task
- Name the five duties of an agent harness and where each is handled
- Take an SDK agent through a deployment checklist: bounds, isolation, credentials, state, telemetry
Agent SDK: Production-Ready Patterns
When the Agent SDK is the right base and when the raw API is, the five things any harness has to get right, and what it takes to run SDK agents on your own infrastructure.
The Agent SDK is Claude Code as a library: a harness you host. Use it when the task needs files, a shell and an open-ended loop. Whichever base you pick, the limits, the sandbox, the credentials and the evals are still yours to set.