claude-agent-sdk
Build autonomous AI agents with Claude Agent SDK. Structured outputs guarantee JSON schema validation, with plugins system and hooks for event-driven workflows. Prevents 14 documented errors. Use when: building coding agents, SRE systems, security auditors, or troubleshooting CLI not found, structured output validation, session forking errors, MCP config issues, subagent cleanup.
npx skills add majiayu000/claude-skill-registry --skill claude-agent-sdk-brendadeeznuts1111-tier-1380-omega --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.
What it does
The skill describes using the Claude Agent SDK to build autonomous AI agents with structured outputs that validate against JSON schemas. It emphasizes an outputFormat mechanism, type safety with Zod, and a plugins system plus hooks for event-driven workflows. It also notes prevention of 14 documented errors and outlines use cases such as building coding agents, SRE systems, security auditors, and troubleshooting CLI not found or MCP config issues.
How it works
The Core API is query(prompt, options) returning an async generator of messages. Key elements include:
- outputFormat: enables structured JSON schema validation and defines the output structure.
- settingSources, canUseTool, agents, mcpServers, permissionMode, betas, sandbox, enableFileCheckpointing, systemPrompt: critical options for configuration.
- System prompts can be simple strings or preset forms, with a preset that includes Claude Code defaults.
- Built-in tools include a variety of utilities (Read, Write, Edit, Bash, etc.), with optional tool control via allowedTools, disallowedTools, and canUseTool callback for dynamic permission logic.
- Plugins and Hooks (12 Hook Events) allow customizing behavior around tool calls, session management, and errors. Hook examples show PreToolUse and PostToolUse usage and a Stop hook for cleanup.
- Subagent orchestration and MCP servers enable subagent definitions and external server configurations for modular tool usage.
When to use it
Use when building agents that require structured, validated outputs, robust error handling, and hook-driven workflows, particularly for security-conscious or tooling-heavy tasks, including coding agents, SRE systems, security auditors, or troubleshooting CLI not found, MCP config issues, and subagent cleanup. Triggers include feature availability like structured outputs and hooks, and the need for strict MCP/config validation.
What it can touch
The skill references:
- Tools: built-in tools such as Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch, Task, NotebookEdit, BashOutput, KillBash, ListMcpResources, ReadMcpResource, AskUserQuestion.
- Hook system: PreToolUse, PostToolUse, Notification, UserPromptSubmit, SubagentStart, SubagentStop, PreCompact, PermissionRequest, Stop, SessionStart, SessionEnd, Error.
- MCP Servers (External, both stdio and HTTP/SSE) with tool definitions via tool(name, description, zodSchema, handler).
- Subagent definitions via AgentDefinition including description, prompt, tools, model, skills, maxTurns.
- Session management options like resume, forkSession, continue, and V2 session APIs.
Caveats
The guide mentions known subagent cleanup issues where subagents may continue running after the parent stops and suggests Stop hook cleanup as a workaround. It also notes that subagent cleanup behavior is under discussion (Issue references) and that V2 APIs exist in preview with unstable naming. License is MIT, and the skill is categorized under Security with declared tool claude-code.
# Claude Agent SDK - Structured Outputs & Error Prevention Guide **Package**: @anthropic-ai/claude-agent-sdk@0.2.12 **Breaking Changes**: v0.1.45 - Structured outputs (Nov 2025), v0.1.0 - No default system prompt, settingSources required --- ## What's New in v0.1.45+ (Nov 2025) **Major Features:** ### 1. Structured Outputs (v0.1.45, Nov 14, 2025) - **JSON schema validation** - Guarantees responses match exact schemas - **`outputFormat` parameter** - Define output structure with JSON schema or Zod - **Access validated results** - Via `message.structured_output` - **Beta header required**: `structured-outputs-2025-11-13` - **Type safety** - Full TypeScript inference with Zod schemas **Example:** ```typescript import { query } from "@anthropic-ai/claude-agent-sdk"; import { z } from "zod"; import { zodToJsonSchema } from "zod-to-json-schema"; const schema = z.object({ summary: z.string(), sentiment: z.enum(['positive', 'neutral', 'negative']), confidence: z.number().min(0).max(1) }); const response = query({ prompt: "Analyze this code review feedback", options: { model: "claude-sonnet-4-5", outputFormat: { type: "json_schema", json_schema: { name: "AnalysisResult", strict: true, schem
- What's New in v0.1.45+ (Nov 2025)
- 1. Structured Outputs (v0.1.45, Nov 14, 2025)
- 2. Plugins System (v0.1.27)
- 3. Hooks System (v0.1.0+)
- 4. Additional Options
- The Complete Claude Agent SDK Reference
- Table of Contents
- Core Query API
- Extended Context (1M Tokens)
- System Prompt Configuration
- Tool Integration (Built-in + Custom)
- AskUserQuestion Tool (v0.1.71+)
- Tools Configuration (v0.1.57+)
- MCP Servers (Model Context Protocol)
What does the claude-agent-sdk skill do?
Build autonomous AI agents with Claude Agent SDK. Structured outputs guarantee JSON schema validation, with plugins system and hooks for event-driven workflows. Prevents 14 documented errors. Use when: building coding agents, SRE systems, security auditors, or troubleshooting CLI not found, structured output validation, session forking errors, MCP config issues, subagent cleanup.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill claude-agent-sdk-brendadeeznuts1111-tier-1380-omega --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.
