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:

DemoProduction concern
hello-worldSmallest agent loop mental model
Chat appStreaming UI and message handling
AskUserQuestionHuman approval and user input
Email agentCustom MCP tools and domain APIs
Research agentSubagent 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 baseline
  • anthropics/claude-agent-sdk-typescript — TypeScript SDK baseline
  • anthropics/claude-agent-sdk-demos — demo staircase
  • anthropics/claude-quickstarts — deployable application examples
  • anthropics/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.