Claude Agent SDK
The Claude Agent SDK embeds the same autonomous loop that powers Claude Code into custom applications. It is an agent runtime — not a prompt wrapper — that gives developers control over tools, permissions, context, sessions, budgets, and validation.
Core capabilities
query()— entry point that starts the agent loop from a prompt and options- Tool permissions — explicit list of which tools can run automatically, require approval, or are blocked
- PreToolUse hooks — policy checkpoints before any tool executes; used for logging, blocking, approval
- Sessions — conversation history containing prompts, tool calls, results, and decisions; supports resume
- Streaming — messages and results streamed as the loop executes; enables live UI and monitoring
- Custom MCP tools — typed domain tools exposed to the agent through the Model Context Protocol
- Subagents — specialist workers with separate prompts, models, and tool lists
Learning path (demo repo)
The demo repository is structured as a staircase of production concerns:
| Demo | Production concern |
|---|---|
hello-world | Smallest agent loop mental model |
| Chat app | Streaming UI and message handling |
AskUserQuestion | Human approval and user input |
| Email agent | Custom MCP tools and domain APIs |
| Research agent | Subagent orchestration and audit hooks |
Start with read-only loops. Add tools and hooks only after observing the message stream. Add write permissions last.
Official repositories
anthropics/claude-agent-sdk-python— Python SDK baselineanthropics/claude-agent-sdk-typescript— TypeScript SDK baselineanthropics/claude-agent-sdk-demos— demo staircaseanthropics/claude-quickstarts— deployable application examplesanthropics/skills— reusable capability patterns (review before adopting)
Design principle
Design every SDK agent around the loop boundary: context in, tools allowed, state persisted, output validated. Sessions and settings are architecture concerns. Build read-only agents before enabling write-capable workflows.
Related
- AgentLoop — the execution cycle the SDK implements
- BoundedAgent — how to apply SDK primitives safely
- ClaudeCowork — Cowork is built on the same agent runtime
- ClaudeSDKAndCowork — synthesis of SDK and Cowork together