claude-agent-sdk
БесплатноБез исполняемых скриптовНе проверенComprehensive knowledge of Claude Agent SDK architecture, tools, hooks, skills, and production patterns. Auto-activates for agent building, SDK integration…
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
Claude Agent SDK - Comprehensive Skill
Overview
The Claude Agent SDK is Anthropic's official framework for building production-ready AI agents with Claude. It provides a high-level abstraction over the Messages API, handling the agent loop, tool orchestration, context management, and extended-thinking patterns automatically.
When to Use the Agent SDK
Use the Agent SDK when:
- Building autonomous agents that need to use tools iteratively
- Implementing agentic workflows with verification and iteration
- Creating subagent hierarchies for complex task decomposition
- Integrating MCP (Model Context Protocol) servers for standardized tools
- Need production patterns like hooks, permissions, and context management
Don't use when:
- Simple single-turn API calls suffice (use Messages API directly)
- No tool use required (standard chat)
- Custom agent loop logic needed (SDK loop is opinionated)
Language Support
- Python:
claude-agentspackage (recommended for most use cases) - TypeScript:
@anthropics/agent-sdkpackage (Node.js environments)
Both implementations share the same core concepts and API patterns.
Quick Start
Installation
Python:
pip install claude-agents
TypeScript:
npm install @anthropics/agent-sdk
Authentication
Set your API key as an environment variable:
export ANTHROPIC_API_KEY="your-api-key-here"
Or pass it explicitly in code:
from claude_agents import Agent
agent = Agent(api_key="your-api-key-here")
Basic Agent Creation
Python Example:
from claude_agents import Agent
# Create agent with default settings
agent = Agent(
model="claude-sonnet-4-5-20250929",
system="You are a helpful assistant focused on accuracy."
)
# Run simple task
result = agent.run("What is 2+2?")
print(result.response)
TypeScript Example:
import { Agent } from "@anthropics/agent-sdk";
const agent = new Agent({
model: "claude-sonnet-4-5-20250929",
system: "You are a helpful assistant focused on accuracy.",
});
const result = await agent.run("What is 2+2?");
console.log(result.response);
First Tool Example
Tools extend agent capabilities with external functions:
Python:
from claude_agents import Agent
from claude_agents.tools import Tool
# Define custom tool
def get_weather(location: str) -> dict:
"""Get weather for a location."""
return {"location": location, "temp": 72, "condition": "sunny"}
weather_tool = Tool(
name="get_weather",
description="Get current weather for a location",
input_schema={
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
},
function=get_weather
)
# Agent with custom tool
agent = Agent(
model="claude-sonnet-4-5-20250929",
tools=[weather_tool]
)
result = agent.run("What's the weather in San Francisco?")
print(result.response)
Core Concepts Reference
The Agent Loop
The SDK manages a complete agent loop automatically:
- Input Processing: User message + system prompt + tools
- Model Invocation: Claude generates response (text or tool calls)
- Tool Execution: SDK executes requested tools, handles results
- Iteration: Results fed back to model, continues until completion
- Output: Final response with full conversation history
Key Properties:
- Automatic iteration until task completion or max turns
- Built-in error handling and retry logic
- Context management with automatic compaction options
- Token budget tracking and optimization
Context Management
The SDK manages conversation context automatically:
Context Components:
- System prompt (persistent instructions)
- Conversation history (user messages + assistant responses)
- Tool definitions (available capabilities)
- Tool results (execution outputs)
Subagents for Context Isolation:
# Spawn subagent with isolated context
with agent.subagent(
system="You are a code reviewer focused on security.",
tools=[security_scan_tool]
) as reviewer:
review = reviewer.run("Review this code for vulnerabilities: ...")
# Subagent context doesn't pollute parent
Context Compaction: When approaching token limits, the SDK can automatically summarize earlier conversation turns while preserving critical information.
Tools System
Tools are the agent's interface to external capabilities.
Built-in Tools:
bash: Execute shell commandsread_file: Read file contentswrite_file: Write data to filesedit_file: Modify existing filesglob: File pattern matchinggrep: Content search
Custom Tool Schema:
Tool(
name="tool_name", # Unique identifier
description="What it does", # Clear capability description
input_schema={ # JSON Schema for parameters
Установить claude-agent-sdk в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл claude-agent-sdk?
Comprehensive knowledge of Claude Agent SDK architecture, tools, hooks, skills, and production patterns. Auto-activates for agent building, SDK integration, tool design, and MCP server tasks.
Как установить скилл claude-agent-sdk?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл claude-agent-sdk запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic