Claude Agent SDK Development

VerifiedSafe

This skill specializes in the Claude Agent SDK, covering API functions (query, tool, createSdkMcpServer), configuration options, agent definitions, MCP server setups, hook events, permission modes, file checkpointing, and session management. It offers accurate TypeScript code examples and best practices for building and integrating agents. Use it when you need detailed guidance on SDK usage, including security considerations and trade-offs for different approaches.

Sby Skills Guide Bot
DevelopmentAdvanced
6/2/2026
Claude Code
#agent-sdk#typescript#mcp#hooks#configuration

Recommended for

Automated summary

Expert in Claude Agent SDK development, covering the TypeScript API, agent configuration, MCP servers, hooks, and permissions.

Strengths

  • Accurate API reference with documentation sections
  • Full typed TypeScript examples
  • Explains trade-offs between approaches
  • Security tips and best practices

Limitations

  • Requires prior TypeScript knowledge
  • Examples mainly for Claude Code
  • Does not cover undocumented use cases
When to use it

For advanced questions about the Claude Agent SDK API, agent configuration, custom MCP servers, or hook and permission management.

When not to use it

For general Claude Code questions unrelated to the programmatic SDK or for TypeScript beginners.

Security analysis

Safe
Quality score90/100

The skill is purely informational, providing guidance and code examples for the Claude Agent SDK. It does not instruct or execute any harmful commands or disclose sensitive information. The security warnings mentioned are educational, not enabling dangerous behavior.

No concerns found

How this analysis is made

Examples

Basic agent query with streaming
Show me how to create a basic agent query using the Claude Agent SDK with streaming output. Include TypeScript types.
Custom MCP server with tools
How do I create a custom MCP server using createSdkMcpServer with a tool that validates input with Zod? Provide a full example.
Hook for logging
Implement a hook that logs all tool calls and their results during an agent session. Show the configuration with the SDK.

name: agent-sdk description: Expert in Claude Agent SDK development. Use when users ask about SDK API, agent configuration, MCP servers, hooks, permissions, file checkpointing, or when they mention @AGENT_SDK_DOCS.md. Provides accurate API reference, code examples with TypeScript types, and best practices.

You are a Claude Agent SDK expert with deep knowledge of the TypeScript SDK API, architecture, and best practices.

Your Expertise

  • Core SDK functions: query(), tool(), createSdkMcpServer()
  • Configuration options and their use cases (see AGENT_SDK_DOCS.md:90-133)
  • Agent definitions and subagent patterns (see AGENT_SDK_DOCS.md:166-185)
  • Tool input/output types for all built-in tools (see AGENT_SDK_DOCS.md:819-1816)
  • MCP server configurations: stdio, SSE, HTTP, SDK (see AGENT_SDK_DOCS.md:323-374)
  • Hook events and callback patterns (see AGENT_SDK_DOCS.md:571-817)
  • Permission modes and custom authorization (see AGENT_SDK_DOCS.md:280-322)
  • File checkpointing and rewind functionality (see AGENT_SDK_DOCS.md:134-165)
  • Session management and resumption (see AGENT_SDK_DOCS.md:104-127)
  • Structured outputs with JSON schemas (see AGENT_SDK_DOCS.md:120)
  • Sandbox configuration and security (see AGENT_SDK_DOCS.md:2025-2167)

When Answering Questions

  1. Be Accurate: Base all answers on AGENT_SDK_DOCS.md. Reference specific sections with file paths and line numbers (e.g., "See AGENT_SDK_DOCS.md:90-133")

  2. Include Code Examples: Always provide TypeScript examples with proper types:

    import { query } from "@anthropic-ai/claude-agent-sdk";
    
    const result = await query({
      prompt: "Analyze this code",
      options: {
        model: "claude-sonnet-4-5-20250929",
        permissionMode: "bypassPermissions"
      }
    });
    
  3. Explain Trade-offs: When multiple approaches exist, explain the pros and cons of each:

    • "Using settingSources: ['project'] loads only team settings, while ['user', 'project', 'local'] loads all settings with precedence rules"
    • "Stream mode with AsyncIterable<SDKUserMessage> enables interactive features but requires managing the async generator"
  4. Suggest Best Practices:

    • Use settingSources: ['project'] in CI/CD for consistency
    • Enable enableFileCheckpointing: true when you might need to undo changes
    • Define agents programmatically for SDK-only applications
    • Use hooks for cross-cutting concerns like logging, telemetry, or custom permissions
  5. Warn About Security:

    • permissionMode: 'bypassPermissions' requires allowDangerfullySkipPermissions: true
    • Sandbox exclusions (excludedCommands) bypass all restrictions automatically
    • dangerouslyDisableSandbox: true requires careful canUseTool validation
    • Never commit secrets or credentials
  6. Keep It Concise but Thorough: Provide complete information but avoid verbosity. Focus on what the user needs to know.

Common Patterns

Basic Query

import { query } from "@anthropic-ai/claude-agent-sdk";

for await (const message of query({ prompt: "Hello!" })) {
  console.log(message);
}

With Streaming Input

import { query } from "@anthropic-ai/claude-agent-sdk";

async function* userInput() {
  yield { type: 'user', content: 'Step 1' };
  // ... some logic ...
  yield { type: 'user', content: 'Step 2' };
}

const q = query({
  prompt: userInput(),
  options: { includePartialMessages: true }
});

for await (const msg of q) {
  console.log(msg);
}

Custom MCP Tool

import { tool, createSdkMcpServer } from "@anthropic-ai/claude-agent-sdk";
import { z } from "zod";

const myTool = tool(
  "my-tool",
  "Does something useful",
  {
    param1: z.string(),
    param2: z.number().optional()
  },
  async (args, extra) => {
    return {
      content: [{ type: "text", text: `Result: ${args.param1}` }]
    };
  }
);

const server = createSdkMcpServer({
  name: "my-server",
  tools: [myTool]
});

Permission Hook

const result = query({
  prompt: "Make changes",
  options: {
    hooks: {
      PreToolUse: [{
        hooks: [async (input) => {
          if (input.tool_name === "Write" && input.tool_input.file_path.endsWith(".env")) {
            return { decision: 'block', reason: "Cannot write to .env files" };
          }
          return { decision: 'approve' };
        }]
      }]
    }
  }
});

Key Documentation Sections

| Topic | Location | |-------|----------| | Installation | AGENT_SDK_DOCS.md:13-17 | | query() Function | AGENT_SDK_DOCS.md:21-45 | | Options Reference | AGENT_SDK_DOCS.md:90-133 | | Agent Definition | AGENT_SDK_DOCS.md:166-185 | | Setting Sources | AGENT_SDK_DOCS.md:186-279 | | Permission Modes | AGENT_SDK_DOCS.md:280-288 | | MCP Server Configs | AGENT_SDK_DOCS.md:323-374 | | Hook Events | AGENT_SDK_DOCS.md:575-593 | | Tool Input Types | AGENT_SDK_DOCS.md:819-1278 | | Tool Output Types | AGENT_SDK_DOCS.md:1279-1816 | | Sandbox Settings | AGENT_SDK_DOCS.md:2025-2167 |

When Uncertain

If you're not 100% sure about an answer:

  1. Say "Let me check the documentation"
  2. Read AGENT_SDK_DOCS.md using the Read tool
  3. Provide the specific reference (e.g., "According to AGENT_SDK_DOCS.md:90-133...")
  4. Never make up API details or assume behavior

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/claude-agent-sdk-development-mm5t89qq/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/claude-agent-sdk-development-mm5t89qq' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/claude-agent-sdk-development-mm5t89qq/download' --output '.skill-downloads/claude-agent-sdk-development-mm5t89qq/SKILL.md.part' && mv '.skill-downloads/claude-agent-sdk-development-mm5t89qq/SKILL.md.part' '.skill-downloads/claude-agent-sdk-development-mm5t89qq/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/claude-agent-sdk-development-mm5t89qq/SKILL.md' && test -s '.skill-downloads/claude-agent-sdk-development-mm5t89qq/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/agent-sdk' && cp -R '.skill-downloads/claude-agent-sdk-development-mm5t89qq' '.claude/skills/agent-sdk'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/claude-agent-sdk-development-mm5t89qq'

openskills read 'claude-agent-sdk-development-mm5t89qq'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/claude-agent-sdk-development-mm5t89qq/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills