Skip to content
Skills Library
AI & agents · Building & coding

claude-agent-sdk

/claude-agent-sdk

Build AI agents using the Claude Agent SDK. Covers query functions, ClaudeSDKClient, custom tools, MCP servers, hooks, permissions, subagents, and browser control (Chrome extension, dev-browser skill). Use when creating agents, adding tools, configuring agent behavior, or automating browser tasks.

Licence
MIT
Last repository change
19.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
22
Scripts
7
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 19.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 7 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: templates/agent-with-tracking-python.py, templates/continuous-chat-python.py, templates/custom-tool-python.py, templates/hook-example-python.py, templates/research-agent-python.py, templates/session-api-typescript.ts, templates/simple-agent-python.py

What it does and when to use it

Build AI agents using the Claude Agent SDK. Covers query functions, ClaudeSDKClient, custom tools, MCP servers, hooks, permissions, subagents, and browser control (Chrome extension, dev-browser skill). Use when creating agents, adding tools, configuring agent behavior, or automating browser tasks.

Original author description

Build AI agents using the Claude Agent SDK. Covers query functions, ClaudeSDKClient, custom tools, MCP servers, hooks, permissions, subagents, and browser control (Chrome extension, dev-browser skill). Use when creating agents, adding tools, configuring agent behavior, or automating browser tasks.

How it works

  1. Claude Agent SDK Overview
  2. What would you like to do?
  3. ClaudeAgentOptions (Key Fields)
  4. Built-in Tools
  5. Message Types
  6. Error Types
  7. Thinking & Effort Configuration
  8. Common Patterns
Original SKILL.md headings · 239 lines, 867 words
SKILL.md preview
---
name: claude-agent-sdk
description: Build AI agents using the Claude Agent SDK. Covers query functions,
  ClaudeSDKClient, custom tools, MCP servers, hooks, permissions, subagents, and
  browser control (Chrome extension, dev-browser skill). Use when creating
  agents, adding tools, configuring agent behavior, or automating browser tasks.
triggers:
  - claude agent sdk
  - agent sdk
  - build agent
  - create agent
  - claude sdk
  - ClaudeSDKClient
  - query function
  - custom tools
  - "@tool decorator"
  - mcp server
  - agent hooks
  - subagent
  - AgentDefinition
  - browser control
  - chrome extension
  - browser automation
  - dev browser
  - browserbase
---

<essential_principles>

## Claude Agent SDK Overview

The Claude Agent SDK gives agents the same tools that power Claude Code:
file operations, bash commands, web search, and more. Build autonomous agents
that read files, run commands, search the web, edit code, and verify their work.

### Two Ways to Query

| Function | Session | Best For |
|----------|---------|----------|
| `query()` | New each time | One-off tasks, automation |
| `ClaudeSDKClient` | Continuous | Conversations, follow-ups, hooks |

**Key Difference:** `query()` is simpler but doesn't support hooks, interrupts, or
custom tools. Use `ClaudeSDKClient` for advanced features.

### Agent Loop Pattern

Agents operate in a feedback loop:
```
gather context → take action → verify work → repeat
```

### Installation

**Python:**
```bash
uv add claude-agent-sdk
```

**TypeScript:**
```bash
npm install @anthropic-ai/claude-agent-sdk
```

**Requirements:**
- Claude Code CLI installed (`npm install -g @anthropic-ai/claude-code`)
- `ANTHROPIC_API_KEY` environment variable set

### Quick Start

```python
import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions

async def main():
    async for message in query(
        prompt="Find and fix bugs in auth.py",
        options=ClaudeAgentOptions(allowed_tools=["Read", "Edit", "Bash"])
    ):
        print(message)

asyncio.run(main())
```

</essential_principles>

<intake>

## What would you like to do?

1. **Create a new agent** - Build an agent from scratch
2. **Add custom tools** - Create tools with @tool decorator or MCP servers
3. **Add hooks** - Intercept tool calls for logging, validation, or modification
4. **Configure permissions** - Control what tools can do
5. **Create subagents** - Define specialized agents for parallel work
6. **Control browsers** - Chrome extension, dev-browser skill
7. **Get API reference** - Python or TypeScript SDK details

**Wait for response before proceeding.**

</intake>

<routing>

| Response | Load |
|----------|------|
| 1, "create", "new", "build" | `workflows/create-agent.md` |
| 2, "tools", "custom", "@tool" | `references/custom-tools.md` |
| 3, "hooks", "intercept" | `references/hooks.md` |
| 4, "permissions", "can_use_tool" | `references/permissions.md` |
| 5, "subagent", "parallel" | `references/subagents.md` |
| 6, "browser", "chrome", "automation" | `references/browser-control.md` |
| 7, "python", "reference" | `references/python-sdk.md` |
| 7, "typescript", "reference" | `references/typescript-sdk.md` |
| "built-in", "tools" | `references/built-in-tools.md` |
| "message", "types" | `references/message-types.md` |
| "best practices", "patterns" | `references/best-practices.md` |
| "error", "troubleshoot" | `references/troubleshooting.md` |

</routing>

<quick_reference>

## ClaudeAgentOptions (Key Fields)

```python
ClaudeAgentOptions(
    # Tools
    allowed_tools=["Read", "Write", "Bash"],  # Built-in tools to enable
    disallowed_tools=["WebSearch"],           # Tools to block

    # Prompts
    system_prompt="You are...",               # Custom system prompt
    # Or use preset: {"type": "preset", "preset": "claude_code", "append": "..."}

    # MCP Servers
    mcp_servers={"calc": my_server},          # MCP server configs

    # Permissions
    permission_mode="acceptEdits",            # default | acceptEdits | plan | bypassPermissions
    can_use_tool=my_handler,                  # Custom permission callback

    # Execution
    cwd="/path/to/project",                   # Working directory
    max_turns=10,                             # Limit iterations
    env={"API_KEY": "..."},                   # Environment variables

    # Advanced
    hooks={"PreToolUse": [...]},              # Behavior hooks
    agents={"researcher": AgentDef(...)},     # Subagents
    sandbox={"enabled": True},                # Sandbox settings
    setting_sources=["project"],              # Load .claude settings
)
```

## Built-in Tools

| Tool | Purpose |
|------|---------|
| **Read** | Read files (text, images, PDFs, notebooks) |
| **Write** | Create new files |
| **Edit** | Modify existing files with search/replace |
| **Bash** | Run terminal commands |
| **Glob** | Find files by pattern (`**/*.ts`) |
| **Grep** | Search file contents with regex |
| **WebSearch** | Search the web |
| **WebFetch** | Fetch and parse web pages |
| **Task** | Spawn subagents |
| **NotebookEdit** | Edit Jupyter notebooks |
| **TodoWrite** | Manage task lists |
| **KillShell** | Kill background shells |
| **ExitPlanMode** | Exit planning mode |

## Message Types

```python
# All messages
Message = UserMessage | AssistantMessage | SystemMessage | ResultMessage

# Content blocks in AssistantMessage
ContentBlock = TextBlock | ThinkingBlock | ToolUseBlock | ToolResultBlock
```

## Error Types

```python
from claude_agent_sdk import (
    CLINotFoundError,      # Claude Code CLI not installed
    CLIConnectionError,    # Connection failed
    ProcessError,          # CLI process failed
    CLIJSONDecodeError,    # JSON parsing failed
)
```

</quick_reference>

<thinking_config>

## Thinking & Effort Configuration

Control agent thinking depth via the effort parameter rather than prompt-level instructions like "think carefully":

| Use Case | Effort | Notes |
|----------|--------|-------|
| Quick lookups, simple edits | low | Minimal thinking overhead |
| Standard development | medium | Default for most agents |
| Complex architecture, security | high | Deeper reasoning |
| Deep research, long-horizon | max | Maximum thinking budget |

```python
# Adaptive thinking (recommended for Claude 4.6)
options = ClaudeAgentOptions(
    model="claude-opus-4-6",  # or claude-sonnet-4-6
    # Effort is controlled at the API level, not in the agent options
)
```

Avoid adding "think carefully" or "be thorough" to agent system prompts—Claude 4.6 calibrates thinking depth automatically based on task complexity.

</thinking_config>

<examples>

## Common Patterns

### File Operations Agent
```python
options = ClaudeAgentOptions(
    allowed_tools=["Read", "Write", "Edit", "Glob", "Grep"],
    permission_mode="acceptEdits",
    cwd="/path/to/project"
)
```

### Code Review Agent
```python
options = ClaudeAgentOptions(
    allowed_tools=["Read", "Glob", "Grep"],  # Read-only
    system_prompt="Review code for bugs, security issues, and style"
)
```

### Research Agent
```python
options = ClaudeAgentOptions(
    allowed_tools=["WebSearch", "WebFetch", "Write"],
    max_turns=20  # Allow more iterations for research
)
```

### Interactive Chat with Tools
```python
async with ClaudeSDKClient(options) as client:
    await client.query("What files are in this directory?")
    async for msg in client.receive_response():
        print(msg)

    # Follow-up - Claude remembers context
    await client.query("Show me the largest one")
    async for msg in client.receive_response():
        print(msg)
```

</examples>
Files in this package (22)
  • README.md 7 KB
  • SKILL.md 7 KB
  • references/best-practices.md 10 KB
  • references/browser-control.md 10 KB
  • references/built-in-tools.md 7 KB
  • references/custom-tools.md 6 KB
  • references/hooks.md 6 KB
  • references/message-types.md 5 KB
  • references/permissions.md 6 KB
  • references/python-sdk.md 10 KB
  • references/subagents.md 12 KB
  • references/troubleshooting.md 6 KB
  • templates/agent-with-tracking-python.py 10 KB
  • templates/continuous-chat-python.py 2 KB
  • templates/custom-tool-python.py 3 KB
  • templates/hook-example-python.py 4 KB
  • templates/research-agent-python.py 7 KB
  • templates/session-api-typescript.ts 7 KB
  • templates/simple-agent-python.py 1 KB
  • workflows/add-custom-tools.md 5 KB
  • workflows/add-hooks.md 7 KB
  • workflows/create-agent.md 4 KB

Versions

RepositoryScoreLicence
This page · tdimino/claude-code-minoan100MIT
emdashcodes/claude-code-plugins100MIT
sammcj/agentic-coding95Apache-2.0
fcsouza/agent-skills95GPL-3.0
LeoYeAI/openclaw-master-skills91MIT

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 13aae757b377 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90claude-agent-sdk-tool-integration
    Use when integrating tools, permissions, and MCP servers with Claude AI agents using the Agent SDK.
  • 100agent-builder
    Build AI agents and automate Claude Code programmatically via the Claude Agent SDK and headless CLI mode. Covers Python SDK, claude -p, SDK MCP servers, hooks, sessions. Triggers on: "build an agent", "agent SDK", "headless mode", "automate Claude", "programmatic agent".
  • 100agent-sdk-quickstart
    Build a first agent with the Claude Agent SDK (TypeScript or Python): install, run query(), read result messages, restrict tools and permissions, add custom tools through an in-process MCP server, and guard tool calls with hooks. Also explains when to pick the Agent SDK, the…
  • 100claude-agent-sdk-voice
    Patterns for using the Python claude-agent-sdk as a low-latency voice brain — streaming partial text, long-lived ClaudeSDKClient sessions, MCP server config (stdio/http/sse + in-process SDK servers), allowed_tools naming, PreToolUse hooks for spoken confirmation, and model…
  • 95claude-sdk
    Build autonomous AI agents with the Claude Agent SDK — computer use, tool calling, MCP integration, and production best practices for Anthropic models. Use when writing agent code against the Claude/Anthropic SDK, wiring tools or MCP servers, or hardening an agent for production.
  • 90migrating-claude-agent-sdk-to-pydantic-ai
    Migrate Python applications from the Claude Agent SDK to Pydantic AI and, only when needed, Pydantic AI Harness. Use when source code imports `claude_agent_sdk` or relies on Claude Code's agent loop, sessions, built-in tools, hooks, permissions, skills, or subagents. Do not use…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.