Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

claude-agent-sdk

БесплатноБез исполняемых скриптовНе проверен

Comprehensive knowledge of Claude Agent SDK architecture, tools, hooks, skills, and production patterns. Auto-activates for agent building, SDK integration…

diegosouzapwот 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-agents package (recommended for most use cases)
  • TypeScript: @anthropics/agent-sdk package (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:

  1. Input Processing: User message + system prompt + tools
  2. Model Invocation: Claude generates response (text or tool calls)
  3. Tool Execution: SDK executes requested tools, handles results
  4. Iteration: Results fed back to model, continues until completion
  5. 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 commands
  • read_file: Read file contents
  • write_file: Write data to files
  • edit_file: Modify existing files
  • glob: File pattern matching
  • grep: Content search

Custom Tool Schema:

Tool(
    name="tool_name",              # Unique identifier
    description="What it does",    # Clear capability description
    input_schema={                 # JSON Schema for parameters
Полный SKILL.md на GitHub

Установить claude-agent-sdk в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

metadata.json

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), без исполняемых скриптов.

Похожие скиллы

Сравнить claude-agent-sdk с