claude-agent-sdk

Build autonomous AI agents with the Anthropic Claude Agent SDK using TypeScript templates and API references.

Updated Dec 4, 2025
One-click install
npx skills add https://github.com/dallascrilley/dowser --skill claude-agent-sdk-dallascrilley
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: claude-agent-sdk
Source: https://github.com/dallascrilley/dowser/tree/main/skills/claude-agent-sdk
Command: npx skills add https://github.com/dallascrilley/dowser --skill claude-agent-sdk-dallascrilley

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @anthropic-ai/claude-agent-sdk, zod, and includes scripts (resource) and references (resource) components.

What problem does it solve? Building autonomous agents with the Claude Agent SDK requires learning a large API surface—query streaming, MCP servers, subagents, sessions, and permissions—which typically leads to hours of trial-and-error and common integration errors. ## Core Features & Use Cases - Complete API Reference: Covers query(), tool integration, MCP server creation with Zod schemas, subagent orchestration, session resume/fork, and permission control. - Production Templates: 11 ready-to-use TypeScript templates including basic queries, custom MCP servers, multi-agent workflows, and error handling with retry and circuit breaker patterns. - Error Prevention: Documents 12 common errors (CLI not found, authentication failed, context length exceeded) with tested solutions. - Use Case: Build a DevOps automation agent that orchestrates specialized subagents for deployment, incident response, monitoring, and security auditing with fine-grained permission controls. ## Quick Start Ask the agent to create a basic Claude Agent SDK query that analyzes your codebase using the Read, Grep, and Glob tools.

Frequently Asked Questions about claude-agent-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build an autonomous agent with the Claude Agent SDK?▼

Install @anthropic-ai/claude-agent-sdk and zod, set your ANTHROPIC_API_KEY, then call the query() function with a prompt and options like model, workingDirectory, and allowedTools. Process the streaming response with an async for-await loop over message types.

How to create custom MCP tools for Claude agents?▼

Use createSdkMcpServer with the tool() helper to define tools with Zod input schemas and async handlers. Register the server in the mcpServers option and reference tools as mcp__server-name__tool-name in allowedTools.

Claude Agent SDK vs direct Claude Messages API?▼

The Agent SDK wraps the Claude Code CLI for agentic workflows with built-in tools, sessions, and subagents. Use the direct Messages API for simple single-turn interactions without tool orchestration or filesystem access.

Why does the Claude Agent SDK throw CLI not found errors?▼

The SDK requires the Claude Code CLI installed globally. Fix it by running npm install -g @anthropic-ai/claude-code and verifying the CLI is on your PATH before executing queries.

How do I resume or fork sessions in the Claude Agent SDK?▼

Capture the session_id from the system init message, then pass it via the resume option to continue the conversation. Add forkSession: true to branch an alternative path without modifying the original session.

When should I not use the Claude Agent SDK?▼

Avoid it for simple single-turn Claude interactions where the direct Messages API is sufficient, or when you need Cloudflare Durable Objects agents. It is designed for multi-step autonomous workflows with tool orchestration.