claude-agent-sdk-python
Expert guidance for building AI agents with the Claude Agent SDK in Python. Use when the user writes Python code with the SDK, imports claude_agent_sdk, uses query(), ClaudeSDKClient, ClaudeAgentOptions, AgentDefinition, creates custom @tool functions, sets up hooks, integrates MCP servers, manages sessions, or debugs SDK issues in Python. Also triggers on: "claude_agent_sdk", "ClaudeAgentOptions", "from claude_agent_sdk import", "pip install claude-agent-sdk", "asyncio.run", or "async for message in query".
npx skills add majiayu000/claude-skill-registry --skill claude-agent-sdk-python --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Claude Agent SDK — Python Guide Production guidance for building AI agents with the Claude Agent SDK in Python. > **Naming**: The Claude Code SDK was renamed to the Claude Agent SDK (v0.1.0+). > Package: `pip install claude-agent-sdk` · Import: `from claude_agent_sdk import ...` ## Message Types All message types for type checking and `isinstance()` checks: ```python from claude_agent_sdk import ( AssistantMessage, # Claude's text/tool responses ResultMessage, # Final result with subtype (success/error/cancelled) SystemMessage, # System events (session_id, etc.) UserMessage, # User prompts ToolUseMessage, # Tool invocation requests ToolResultMessage, # Tool execution results ) ``` ## Quick Reference — Two Interaction Modes ### 1. `query()` — Stateless, One-Shot Best for: independent tasks, automation scripts, CI pipelines. ```python import asyncio from claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, ResultMessage async def main(): async for message in query( prompt="Review utils.py for bugs. Fix any issues you find.", options=ClaudeAgentOptions( allowed_tools=["Read", "Edit", "Glob"], permission_mode="acceptEdits", ), ): if isinstance(message, AssistantMessag
- Message Types
- Quick Reference — Two Interaction Modes
- 1. query() — Stateless, One-Shot
- 2. ClaudeSDKClient — Stateful, Multi-Turn
- ClaudeAgentOptions — Complete Configuration
- Built-in Tools
- Custom Tools via SDK MCP Server
- Subagents
- Hooks — Lifecycle Callbacks
- MCP Integration (External Servers)
- Using Skills in the SDK
- Sessions and Conversation Management
- System Prompt Configuration
- Authentication
Direct API (default) export ANTHROPIC_API_KEY=your-api-key Amazon Bedrock export CLAUDE_CODE_USE_BEDROCK=1 Google Vertex AI export CLAUDE_CODE_USE_VERTEX=1 Microsoft Azure AI Foundry export CLAUDE_CODE_USE_FOUNDRY=1
What does the claude-agent-sdk-python skill do?
Expert guidance for building AI agents with the Claude Agent SDK in Python. Use when the user writes Python code with the SDK, imports claude_agent_sdk, uses query(), ClaudeSDKClient, ClaudeAgentOptions, AgentDefinition, creates custom @tool functions, sets up hooks, integrates MCP servers, manages sessions, or debugs SDK issues in Python. Also triggers on: "claude_agent_sdk", "ClaudeAgentOptions", "from claude_agent_sdk import", "pip install claude-agent-sdk", "asyncio.run", or "async for message in query".
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill claude-agent-sdk-python --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
