claude-agent-sdk

Installation
Summary

Build autonomous AI agents with structured JSON validation, event-driven hooks, and 14 documented error preventions.

  • Structured outputs (v0.1.45+) guarantee JSON schema validation with full TypeScript inference via Zod or raw schemas
  • 12 hook events (PreToolUse, PostToolUse, SubagentStart, SubagentStop, etc.) enable event-driven workflows, custom permission logic, and cleanup patterns
  • MCP server integration supports stdio, HTTP, and SSE transports with tool naming conventions and strict configuration validation
  • Session management includes forking for safe exploration, V2 preview APIs for simpler multi-turn patterns, and file checkpointing for rollback capability
  • Permission control via canUseTool callbacks and sandbox settings for secure execution with auto-approval logic and excluded command lists
  • Prevents 14 documented issues including CLI not found, context length session-breaking, MCP config gotchas (missing type field), Unicode line separator parsing, and subagent cleanup orphaning
SKILL.md

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:

Related skills
Installs
423
GitHub Stars
776
First Seen
Jan 20, 2026