agent-sdk
# Claude Agent SDK
What this skill does
# Claude Agent SDK
Complete guide to the Claude Agent SDK for building custom AI agents.
## Overview
The Claude Agent SDK allows you to programmatically spawn and control Claude Code sessions from TypeScript/JavaScript or Python applications.
## Installation
### TypeScript/JavaScript
```bash
npm install @anthropic-ai/claude-agent-sdk
# or
pnpm add @anthropic-ai/claude-agent-sdk
```
### Python
```bash
# Using uv (recommended)
uv init && uv add claude-agent-sdk
# Using pip
python3 -m venv .venv && source .venv/bin/activate
pip3 install claude-agent-sdk
```
**Prerequisite:** Claude Code CLI must be installed:
```bash
curl -fsSL https://claude.ai/install.sh | bash
```
**Required env var:** `ANTHROPIC_API_KEY`
## Basic Usage
```typescript
import { claude } from "@anthropic-ai/claude-code-sdk";
// Simple query
const response = await claude("What files are in this directory?");
console.log(response.text);
// With options
const response = await claude("Refactor this function", {
model: "claude-sonnet-4-6",
maxTurns: 10,
cwd: "/path/to/project",
allowedTools: ["Read", "Write", "Edit", "Glob", "Grep"],
});
```
## Python SDK
```python
import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions
async def main():
async for message in query(
prompt="Find and fix the bug in auth.py",
options=ClaudeAgentOptions(
allowed_tools=["Read", "Edit", "Bash"],
permission_mode="acceptEdits",
),
):
print(message)
asyncio.run(main())
```
### Python Options
```python
ClaudeAgentOptions(
allowed_tools=["Read", "Edit", "Bash"],
permission_mode="acceptEdits", # default, acceptEdits, dontAsk, bypassPermissions, plan
system_prompt="Custom prompt",
agents={"reviewer": AgentDefinition(
description="Expert code reviewer",
prompt="Analyze code quality.",
tools=["Read", "Glob", "Grep"],
)},
mcp_servers={"playwright": {...}},
)
```
## TypeScript Streaming
```typescript
import { query } from "@anthropic-ai/claude-agent-sdk";
// Stream responses
for await (const message of query({
prompt: "Explain this codebase",
options: {
allowedTools: ["Read", "Glob", "Grep"],
}
})) {
console.log(message);
}
```
## Event Types
```typescript
interface TextEvent {
type: "text";
text: string;
}
interface ToolUseEvent {
type: "tool_use";
name: string;
input: Record<string, unknown>;
id: string;
}
interface ToolResultEvent {
type: "tool_result";
tool_use_id: string;
content: string;
is_error: boolean;
}
interface StopEvent {
type: "stop";
reason: "end_turn" | "max_turns" | "error";
}
```
## Options
```typescript
interface ClaudeOptions {
// Model selection
model?: string; // Claude model to use
// Conversation control
maxTurns?: number; // Max agentic turns
systemPrompt?: string; // Override system prompt
appendSystemPrompt?: string; // Append to system prompt
// Working directory
cwd?: string; // Working directory for file operations
// Permissions
allowedTools?: string[]; // Allowed tools list
disallowedTools?: string[]; // Denied tools list
permissionMode?: "default" | "plan" | "bypassPermissions";
// Session management
sessionId?: string; // Resume existing session
continue?: boolean; // Continue last session
// MCP
mcpConfig?: string; // Path to MCP config file
// Environment
env?: Record<string, string>; // Additional env vars
// Input
inputFormat?: "text" | "stream-json";
// Abort
abortSignal?: AbortSignal; // Cancel the request
}
```
## Built-in Sub-Agent Types
When using the `Agent` tool within Claude Code, these sub-agent types are available:
| Type | Purpose | Tools Available |
|------|---------|----------------|
| `general-purpose` | Multi-step tasks, code search | All tools |
| `Explore` | Fast codebase exploration | Read-only tools |
| `Plan` | Architecture & implementation planning | Read-only tools |
| `claude-code-guide` | Claude Code feature questions | Read-only + web |
| `researcher` | Deep research with web access | Read-only + web |
| `test-writer` | Write comprehensive tests | All tools |
| `code-reviewer` | Code review and quality | Read-only + Bash |
| `debugger` | Debug errors and failures | All tools |
| `doc-writer` | Documentation generation | Write tools |
| `security-reviewer` | Security audit | Read-only + Bash |
| `regex-expert` | Regular expression design | Read/Write tools |
| `prisma-specialist` | Prisma ORM operations | All tools |
| `redis-specialist` | Redis caching patterns | All tools |
| `graphql-specialist` | GraphQL API design | All tools |
| `infrastructure-specialist` | Distributed systems, k8s | All tools |
| `docker-ops` | Docker build and registry | Read-only + Bash |
| `k8s-image-auditor` | K8s deployment auditing | Read-only + Bash |
| `ansible-specialist` | Ansible automation | All tools |
| `pulumi-specialist` | Pulumi IaC | All tools |
| `coverage-analyzer` | Test coverage analysis | All tools |
| `spec-validator` | API spec validation | All tools |
| `rabbitmq-specialist` | RabbitMQ messaging | All tools |
| `event-streaming-architect` | CQRS/event sourcing | All tools |
| `kafka-specialist` | Apache Kafka streaming | All tools |
| `plugin-manager` | Claude Code plugin management | All tools |
| `statusline-setup` | Claude Code status line config | Read + Edit |
### Agent Lifecycle & Orchestration
When spawning agents, Claude should **prefer to orchestrate** — delegate work to
specialist agents rather than doing it directly. Key principles:
1. **Track all agent IDs** — record every ID returned from Agent tool calls
2. **Check in on background agents** — use `SendMessage(to: agent_id)` every 2 min
3. **Audit every output** — spawn a second agent to review the first agent's work
4. **Clean up idle agents** — terminate agents idle >3 min with no planned follow-up
5. **Use `run_in_background: true`** for independent work you don't need immediately
6. **Use `isolation: "worktree"`** for agents that write code to prevent conflicts
### Agent Naming for Resumption
Name your agents for easy resumption:
```
Agent(name="builder-1", subagent_type="general-purpose", ...)
Agent(name="auditor-1", subagent_type="code-reviewer", ...)
# Later, resume:
SendMessage(to: "builder-1", message: "Fix the issues found in audit")
```
## Multi-Agent Patterns
### Parallel Research
```typescript
import { claude } from "@anthropic-ai/claude-code-sdk";
// Run multiple agents in parallel
const [security, performance, docs] = await Promise.all([
claude("Review security of auth module", {
allowedTools: ["Read", "Glob", "Grep"],
}),
claude("Profile and optimize the API routes", {
allowedTools: ["Read", "Glob", "Grep", "Bash"],
}),
claude("Generate API documentation", {
allowedTools: ["Read", "Glob", "Grep", "Write"],
}),
]);
```
### Pipeline Pattern
```typescript
// Step 1: Research
const research = await claude("Analyze the authentication system");
// Step 2: Plan based on research
const plan = await claude(`Based on this analysis: ${research.text}\n\nCreate an implementation plan`);
// Step 3: Implement based on plan
const impl = await claude(`Implement this plan: ${plan.text}`, {
allowedTools: ["Read", "Write", "Edit", "Bash"],
});
```
### Supervisor Pattern
```typescript
import { claude } from "@anthropic-ai/claude-code-sdk";
async function supervisedTask(task: string) {
// Worker does the task
const result = await claude(task, {
maxTurns: 20,
allowedTools: ["Read", "Write", "Edit", "Bash", "Glob", "Grep"],
});
// Reviewer checks the work
const review = await claude(
`Review this work for quality and correctness:\n\nTask: ${task}\n\nResult: ${result.text}`,
{
allowedTools: ["Read", "Glob", "Grep"],
}
);
return { resulRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.