Help us improve
Share bugs, ideas, or general feedback.
From anthropic-docs
Router skill for the Claude Agent SDK — Anthropic's libraries for building autonomous AI agents that wrap the Claude Code CLI runtime. Ships in TypeScript (`@anthropic-ai/claude-agent-sdk` on npm) and Python (`claude-agent-sdk` on PyPI). Covers `query()` / `ClaudeSDKClient`, hooks (PreToolUse / PostToolUse / Stop / etc.), subagents, MCP servers (stdio / HTTP / SSE / SDK in-process), permission modes, the sandbox (Docker / Kubernetes), structured outputs (JSON Schema validation), session capture / resume / fork, and session storage adapters (`SessionStore`, `InMemorySessionStore`, S3/Redis/Postgres). Use when the user asks about: importing `@anthropic-ai/claude-agent-sdk` in TypeScript or `from claude_agent_sdk import ...` in Python, writing an agent that uses `query()` or `ClaudeSDKClient`, registering hooks via the SDK (`hooks: { PreToolUse: [...] }` / `hooks={"PreToolUse": [...]}`), defining MCP servers in SDK options, configuring `permissionMode` / `permission_mode`, building subagents with `AgentDefinition`, enabling structured outputs, running agents in a Docker/K8s sandbox, capturing and resuming sessions, mirroring session transcripts to external storage (S3, Redis, Postgres) via `SessionStore`, or troubleshooting SDK-specific errors (the SDK wraps Claude Code, so its errors differ from raw Messages API errors). Skip: questions about the Claude Code CLI itself such as `.claude/ settings.json` or `.mcp.json` files (use claude-code), the Anthropic Messages API directly without the SDK (use anthropic-api), the MCP protocol spec itself (use mcp-spec), or Anthropic's hosted Managed Agents product (use anthropic-platform-features).
npx claudepluginhub xiaolai/claude-plugin-marketplace --plugin anthropic-docsHow this skill is triggered — by the user, by Claude, or both
Slash command
/anthropic-docs:claude-agent-sdkThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
| | TypeScript | Python |
Guides Next.js Cache Components and Partial Prerendering (PPR): 'use cache' directives, cacheLife(), cacheTag(), revalidateTag() for caching, invalidation, static/dynamic optimization. Auto-activates on cacheComponents: true.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Breaks plans, specs, or PRDs into thin vertical-slice issues on the project issue tracker using tracer bullets. Useful for converting high-level work into grabbable implementation tickets.
Share bugs, ideas, or general feedback.
| TypeScript | Python | |
|---|---|---|
| Version | v0.3.145 | v0.2.82 |
| Package | @anthropic-ai/claude-agent-sdk | claude-agent-sdk (PyPI) |
| Docs | TypeScript SDK | Python SDK |
| Repo | claude-agent-sdk-typescript | claude-agent-sdk-python |
| Full reference | SKILL-typescript.md | SKILL-python.md |
.ts files, TypeScript imports, or npm/node → read SKILL-typescript.md.py files, Python imports, or pip/python → read SKILL-python.md| Concept | TypeScript | Python |
|---|---|---|
| One-shot query | query(options) | query(options) |
| Stateful client | N/A (query manages state) | ClaudeSDKClient |
| Options type | Options interface | ClaudeAgentOptions dataclass |
| Tool definition | tool(name, schema, handler) | @tool(name, desc, schema) decorator |
| MCP server factory | createSdkMcpServer() | create_sdk_mcp_server() |
| Permission callback | canUseTool | can_use_tool |
| Permission mode | permissionMode: "..." | permission_mode="..." |
| Hook registration | hooks: { PreToolUse: [...] } | hooks={"PreToolUse": [...]} |
| System prompt | systemPrompt | system_prompt |
| Max turns | maxTurns | max_turns |
| Allowed tools | allowedTools | allowed_tools |
| MCP servers | mcpServers | mcp_servers |
| Subagent def | AgentDefinition | AgentDefinition dataclass |
Both SDKs wrap the Claude Code CLI and share these concepts:
SessionStore)For API details, code examples, options tables, and known issues, read the language-specific reference file.