The Agent SDK
The Claude Agent SDK is Claude Code as a library — the same agentic loop, tools, and context management, embedded in your Python or TypeScript application. Use it for CI bots, review pipelines, and production agents.
from claude_agent_sdk import query
async def main(): async for message in query( prompt="Find and fix the failing test in this repo", options={ "allowed_tools": ["Read", "Grep", "Bash", "Edit"], "permission_mode": "acceptEdits", "cwd": "/work/my-repo", }, ): print(message)The SDK inherits the Claude Code feature set: CLAUDE.md and skills can load into SDK agents, hooks intercept behavior at the same lifecycle points, subagents isolate context, and MCP servers connect external tools (including in-process custom tools — your own functions exposed to Claude). Sessions persist and can resume/fork; permissions are declarative allow/deny rules plus modes, exactly as in the CLI.
For quick scripting without the SDK, claude -p "prompt" runs headless from any shell.
Check your understanding
Section titled “Check your understanding”Question 1What is the Agent SDK, conceptually?
Same agentic harness, programmatic surface, Python or TypeScript.
Question 2Which Claude Code features carry over to SDK agents?
The SDK exposes the whole feature set for production use.