From claude-agent-sdk-python-skill
Use this skill WHENEVER the user is building, debugging, or reasoning about Python code that uses claude_agent_sdk (query, ClaudeSDKClient, ClaudeAgentOptions, hooks, MCP tools, subagents, or permissions). Triggers on imports of claude_agent_sdk, mentions of "Agent SDK", "claude-agent-sdk", or questions about building agents in Python. Does NOT trigger for the TypeScript SDK or the Anthropic Client SDK (anthropic.Anthropic / messages.create).
npx claudepluginhub efacsen/claude-agent-sdk-python-skill --plugin claude-agent-sdk-python-skillThis skill uses the workspace's default tool permissions.
Use this skill as the authoritative guide for building, debugging, auditing, or explaining Python code that uses the `claude_agent_sdk` package.
checklists/architecture.mdchecklists/mechanics.mdchecklists/security.mdchecklists/testing.mdreferences/01-api-core.mdreferences/02-options.mdreferences/03-messages.mdreferences/04-hooks.mdreferences/05-mcp-tools.mdreferences/06-permissions.mdreferences/07-sessions.mdreferences/08-errors.mdreferences/sources.jsontemplates/01_one_shot_query.pytemplates/02_interactive_client.pytemplates/03_with_hooks.pytemplates/04_with_mcp_tool.pytemplates/05_with_subagent.pytemplates/06_session_resume.pytemplates/07_tested_agent.pyCreates new Angular apps using Angular CLI with flags for routing, SSR, SCSS, prefixes, and AI config. Follows best practices for modern TypeScript/Angular development. Use when starting Angular projects.
Generates Angular code and provides architectural guidance for projects, components, services, reactivity with signals, forms, dependency injection, routing, SSR, ARIA accessibility, animations, Tailwind styling, testing, and CLI tooling.
Executes ctx7 CLI to fetch up-to-date library documentation, manage AI coding skills (install/search/generate/remove/suggest), and configure Context7 MCP. Useful for current API refs, skill handling, or agent setup.
Use this skill as the authoritative guide for building, debugging, auditing, or explaining Python code that uses the claude_agent_sdk package.
claude_agent_sdk, "Agent SDK" (Python), query(), ClaudeSDKClient, ClaudeAgentOptions, hooks, @tool, create_sdk_mcp_server, or agent subagentsfrom claude_agent_sdk import ....py file that uses claude_agent_sdk@anthropic-ai/claude-agent-sdk → that's the TypeScript SDK. This skill is Python-only.anthropic or uses anthropic.Anthropic() / client.messages.create() → that's the Anthropic Client SDK, a different product with no hooks, no MCP, no permission modes.claude_code_sdk → that's the legacy name. Direct users to migrate to claude_agent_sdk and point at the migration guide.Before writing any SDK code, walk this tree explicitly. Tell the user which branch you took.
One-shot or multi-turn?
query() from templates/01_one_shot_query.pyinterrupt() → ClaudeSDKClient from templates/02_interactive_client.pyDoes it need custom tools that Claude should call?
@tool + create_sdk_mcp_server (templates/04_with_mcp_tool.py). Reference: references/05-mcp-tools.md.mcp_servers= config. Reference: references/05-mcp-tools.md.Does it need guardrails, auditing, or dynamic input transformation around tool calls?
hooks with HookMatcher (templates/03_with_hooks.py). Reference: references/04-hooks.md.Does it need specialized subagents with their own prompts/tools?
agents= in options with AgentDefinition (templates/05_with_subagent.py).Should it load .claude/skills/, .claude/commands/, or CLAUDE.md from disk?
setting_sources=["project"] explicitly. Default is now None — don't assume .claude/ loads automatically.setting_sources unset.Permission posture:
permission_mode="default" or "acceptEdits"permission_mode="dontAsk" (pre-approve via allowed_tools)permission_mode="plan""bypassPermissions" without explicit user acknowledgement and a threat model in the generated code's docstring. If the user asks for it, push back first.Does it need multi-query session continuity?
session_id from SystemMessage(subtype="init"), pass as resume= in next query (templates/06_session_resume.py). Reference: references/07-sessions.md.If the user's request is ambiguous on any routing branch, ask 1–3 of these questions (multi-choice format preferred):
.claude/skills/ or CLAUDE.md from the project directory?"Don't ask all of them. Pick the 1–3 whose answers you can't infer.
Before emitting any code:
templates/. Read it with the Read tool. Do not generate from memory.references/*.md file(s) to verify API signatures — references/02-options.md for ClaudeAgentOptions fields, references/04-hooks.md for hook shapes, etc.# see references/04-hooks.md.checklists/mechanics.md — async usage, isinstance dispatch, hook signatureschecklists/security.md — permission modes, allowed_tools, secretschecklists/architecture.md — primitive choice, compositionchecklists/testing.md — test presence, mocking
Fix violations before showing code to the user.On every invocation, read references/sources.json. For each entry, compare last_fetched to today. If any entry is older than 30 days, emit a single-line warning to the user:
"Snapshot is N days old — run
/agent-sdk:refreshto update."
Never block on this. Never auto-refresh. Never silently trust training data — always consult the snapshot or WebFetch the live doc.
If the user's specific question isn't answered by the snapshot, WebFetch https://code.claude.com/docs/en/agent-sdk/python, answer from the live content, and tell the user the snapshot is missing the topic.
permission_mode="bypassPermissions" without explicit user acknowledgement AND a documented threat model in the generated code's docstring. Push back if the user asks for it casually.AssistantMessage via isinstance, not hasattr:
if isinstance(message, AssistantMessage):
for block in message.content:
if isinstance(block, TextBlock):
print(block.text)
elif isinstance(block, ToolUseBlock):
...
setting_sources explicitly when the user expects .claude/skills, .claude/commands, or CLAUDE.md to load. The default is now None.session_id from SystemMessage(subtype="init") when sessions are in play. Never hardcode a session id.create_sdk_mcp_server) over stdio for SDK-internal tools. No subprocess overhead.ANTHROPIC_API_KEY or any other secret. Always use environment variables.isinstance, not hasattr, for message dispatch. hasattr passes on unrelated types by accident.query — see templates/07_tested_agent.py.async def my_hook(input_data: dict, tool_use_id: str | None, context: HookContext) -> dict:
...
Permission decisions in hooks must return:
{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "deny", "permissionDecisionReason": "..."}}
claude_agent_sdk version differs from the snapshot date, warn about drift and suggest /agent-sdk:refresh.