claude-agent-sdk
Build autonomous AI agents with Claude Agent SDK. Structured outputs (v0.1.45, Nov 2025) guarantee JSON schema validation, plugins system, hooks for…

Установить claude-agent-sdk в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Claude Agent SDK - Structured Outputs & Error Prevention Guide
Package: @anthropic-ai/[email protected] (Nov 21, 2025) 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
outputFormatparameter - 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:
import { query } from "@anthropic-ai/claude-agent-sdk";
import { z } from "zod";
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,
schema: zodToJsonSchema(schema)
}
}
}
});
for await (const message of response) {
if (message.type === 'result' && message.structured_output) {
// Guaranteed to match schema
const validated = schema.parse(message.structured_output);
console.log(`Sentiment: ${validated.sentiment}`);
}
}
2. Plugins System (v0.1.27)
pluginsarray - Load local plugin paths- Custom plugin support - Extend agent capabilities
3. Hooks System (v0.1.0+)
- Event-driven callbacks - PreToolUse, PostToolUse, Notification, UserPromptSubmit
- Session event hooks - Monitor and control agent behavior
4. Additional Options
fallbackModel- Automatic model fallback on failuresmaxThinkingTokens- Control extended thinking budgetstrictMcpConfig- Strict MCP configuration validationcontinue- Resume with new prompt (differs fromresume)permissionMode: 'plan'- New permission mode for planning workflows
📚 Docs: https://platform.claude.com/docs/en/agent-sdk/structured-outputs
The Complete Claude Agent SDK Reference
Table of Contents
- Core Query API
- Tool Integration
- MCP Servers
- Subagent Orchestration
- Session Management
- Permission Control
- Filesystem Settings
- Message Types & Streaming
- Error Handling
- Known Issues
Core Query API
Key signature:
query(prompt: string | AsyncIterable<SDKUserMessage>, options?: Options)
-> AsyncGenerator<SDKMessage>
Critical Options:
outputFormat- Structured JSON schema validation (v0.1.45+)settingSources- Filesystem settings loading ('user'|'project'|'local')canUseTool- Custom permission logic callbackagents- Programmatic subagent definitionsmcpServers- MCP server configurationpermissionMode- 'default'|'acceptEdits'|'bypassPermissions'|'plan'
Tool Integration (Built-in + Custom)
Tool Control:
allowedTools- Whitelist (takes precedence)disallowedTools- BlacklistcanUseTool- Custom permission callback (see Permission Control section)
Built-in Tools: Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch, Task, NotebookEdit, BashOutput, KillBash, ListMcpResources, ReadMcpResource
MCP Servers (Model Context Protocol)
Server Types:
- In-process -
createSdkMcpServer()withtool()definitions - External - stdio, HTTP, SSE transport
Tool Definition:
tool(name: string, description: string, zodSchema, handler)
Handler Return:
{ content: [{ type: "text", text: "..." }], isError?: boolean }
External MCP Servers (stdio)
const response = query({
prompt: "List files and analyze Git history",
options: {
mcpServers: {
// Filesystem server
"filesystem": {
command: "npx",
args: ["@modelcontextprotocol/server-filesystem"],
env: {
ALLOWED_PATHS: "/Users/developer/projects:/tmp"
}
},
// Git operations server
"git": {
command: "npx",
args: ["@modelcontextprotocol/server-git"],
env: {
GIT_REPO_PATH: "/Users/developer/projects/my-repo"
}
}
},
allowedTools: [
"mcp__filesystem__list_files",
"mcp__filesystem__read_file",
"mcp__git__log",
"mcp__git__diff"
]
}
});
External MCP Servers (HTTP/SSE)
const response = query({
prompt: "Analyze data from
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- .claude-plugin/plugin.json
- README.md
- references/mcp-servers-guide.md
- references/permissions-guide.md
- references/query-api-reference.md
- references/session-management.md
- references/subagents-patterns.md
- references/top-errors.md
- scripts/check-versions.sh
- templates/basic-query.ts
- templates/custom-mcp-server.ts
- templates/error-handling.ts
- templates/filesystem-settings.ts
- templates/multi-agent-workflow.ts
- templates/package.json
- templates/permission-control.ts
- templates/query-with-tools.ts
- templates/session-management.ts
- templates/subagents-orchestration.ts
- templates/tsconfig.json
FAQ
Что делает скилл claude-agent-sdk?
Build autonomous AI agents with Claude Agent SDK. Structured outputs (v0.1.45, Nov 2025) guarantee JSON schema validation, plugins system, hooks for event-driven workflows. Use when: building coding agents with validated JSON responses, SRE systems, security auditors, or troubleshooting CLI not found, structured output validation, session forking errors.
Как установить скилл claude-agent-sdk?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл claude-agent-sdk запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
