Token导航 LogoToken导航

Agent Skill · 研究检索

claude-agent-sdk(Claude Agent SDK 搜索)

claude-agent-sdk 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

claude-agent-sdk 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 35,149。

总安装 2,133周安装 88GitHub Stars 55下载 697核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:claude-agent-sdk(Claude Agent SDK 搜索)
来源仓库:https://github.com/rysweet/amplihack
仓库路径:skills/claude-agent-sdk
安装命令:
npx skills add https://github.com/rysweet/amplihack --skill claude-agent-sdk
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/rysweet/amplihack --skill claude-agent-sdk

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于查找、检索和筛选相关信息。适合根据关键词、任务场景或来源线索快速定位候选结果。可结合来源仓库和原始 README 核验具体用法。安装前建议确认权限范围、维护状态及是否触发联网或文件读写。

安装命令:npx skills add https://github.com/rysweet/amplihack --skill claude-agent-sdk

来源仓库内路径:skills/claude-agent-sdk

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/rysweet/amplihack --skill claude-agent-sdk;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

claude-agent-sdk 怎么安装?

在终端执行 npx skills add https://github.com/rysweet/amplihack --skill claude-agent-sdk。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

claude-agent-sdk 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

claude-agent-sdk 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

claude-agent-sdk 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

claude-agent-sdk 用的人多吗?

公开数据是累计安装 2,133 次,近一周安装 88 次,下载 697 次,GitHub 55 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

claude-agent-sdk 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
claude-agent-sdk

Claude Agent SDK 搜索 · 本页

2,13355接触敏感数据未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

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"  # pragma: allowlist secret

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
        "type": "object",
        "properties": {...},
        "required": [...]
    },
    function=callable              # Python function or async function
)

MCP Integration: The SDK can use Model Context Protocol (MCP) servers as tool providers:

from claude_agents import Agent
from claude_agents.mcp import MCPClient

# Connect to MCP server
mcp_client = MCPClient("npx", ["-y", "@modelcontextprotocol/server-filesystem"])

agent = Agent(
    model="claude-sonnet-4-5-20250929",
    mcp_clients=[mcp_client]
)

Permissions System

Control which tools agents can access:

Allowed Tools (Whitelist):

agent = Agent(
    model="claude-sonnet-4-5-20250929",
    tools=[tool1, tool2, tool3, tool4],
    allowed_tools=["tool1", "tool2"]  # Only these can be used
)

Disallowed Tools (Blacklist):

agent = Agent(
    model="claude-sonnet-4-5-20250929",
    tools=[tool1, tool2, tool3],
    disallowed_tools=["tool3"]  # All except tool3
)

Permission Modes:

  • "strict": Agent MUST get permission before tool use (via hooks)
  • "permissive": Agent can use allowed tools freely (default)

Hooks System

Hooks provide lifecycle event interception for observability, validation, and control.

Available Hooks:

  • PreToolUseHook: Before tool execution (validation, logging, blocking)
  • PostToolUseHook: After tool execution (logging, result modification)
  • PreSubagentStartHook: Before subagent spawns (context setup)
  • PostSubagentStopHook: After subagent completes (result processing)

Basic Hook Example:

from claude_agents.hooks import PreToolUseHook

class LoggingHook(PreToolUseHook):
    async def execute(self, context):
        print(f"Tool: {context.tool_name}")
        print(f"Args: {context.tool_input}")
        return context  # Allow execution

agent = Agent(
    model="claude-sonnet-4-5-20250929",
    hooks=[LoggingHook()]
)

Blocking Tool Use:

class ValidationHook(PreToolUseHook):
    async def execute(self, context):
        if context.tool_name == "bash" and "rm -rf" in context.tool_input.get("command", ""):
            raise PermissionError("Destructive command blocked")
        return context

Common Patterns

File Operations

from claude_agents import Agent

agent = Agent(
    model="claude-sonnet-4-5-20250929",
    allowed_tools=["read_file", "write_file", "glob"]
)

result = agent.run(
    "Read all Python files in ./src and create a summary in summary.md"
)

Code Execution

agent = Agent(
    model="claude-sonnet-4-5-20250929",
    allowed_tools=["bash"]
)

result = agent.run(
    "Run the test suite and analyze any failures"
)

Agentic Search (Gather-Act Pattern)

# Agent automatically gathers information iteratively
search_agent = Agent(
    model="claude-sonnet-4-5-20250929",
    tools=[web_search_tool, read_url_tool]
)

result = search_agent.run(
    "Research the latest developments in quantum computing and summarize key papers"
)

Subagent Delegation

main_agent = Agent(model="claude-sonnet-4-5-20250929")

# Delegate specialized task to subagent
with main_agent.subagent(
    system="You are an expert data analyzer.",
    tools=[analyze_csv_tool, plot_tool]
) as analyzer:
    analysis = analyzer.run("Analyze sales_data.csv and create visualizations")

# Results available to main agent
main_agent.run(f"Based on this analysis: {analysis.response}, what actions should we take?")

Error Handling

from claude_agents import Agent, AgentError

agent = Agent(model="claude-sonnet-4-5-20250929")

try:
    result = agent.run("Your task here", max_turns=10)
except AgentError as e:
    print(f"Agent failed: {e}")
    print(f"Turns completed: {e.turns_completed}")
    print(f"Last message: {e.last_message}")

Verification Pattern

# Agent can self-verify results
agent = Agent(
    model="claude-sonnet-4-5-20250929",
    tools=[calculator_tool, verify_tool]
)

result = agent.run(
    "Calculate the compound interest for $10000 at 5% for 10 years. "
    "Verify your calculation by computing it a second way."
)

Navigation Guide

When to Read Supporting Files

reference.md - Read when you need:

  • Deep understanding of agent loop internals
  • Complete API reference for all SDK features
  • Detailed tool schema specifications
  • Permission and security configuration options
  • Comprehensive hooks reference with all event types
  • Skills system implementation details

examples.md - Read when you need:

  • Working code examples for specific patterns
  • Tool implementation templates
  • Hook implementation examples
  • Advanced patterns (subagents, verification, error recovery)
  • Integration examples with existing systems

patterns.md - Read when you need:

  • Production-ready architectural patterns
  • Agent loop optimization strategies (Gather, Act, Verify, Iterate)
  • Context management best practices
  • Tool design principles
  • Security patterns and anti-patterns
  • Performance optimization techniques

drift-detection.md - Read when you need:

  • Understanding how this skill stays current
  • Implementing drift detection for other skills
  • Update workflow and validation processes
  • Self-validation mechanisms

Integration with Amplihack

The Agent SDK skill integrates with the Amplihack framework:

Creating Amplihack Agents with SDK:

# In .claude/agents/amplihack/specialized/my_agent.md
# Use Agent SDK patterns for tool-using agents
from claude_agents import Agent
from claude_agents.tools import Tool

def create_specialized_agent():
    return Agent(
        model="claude-sonnet-4-5-20250929",
        system="<agent_role_from_md>",
        tools=[...],  # Custom tools for this agent
        hooks=[...]   # Logging, validation hooks
    )

Using MCP Servers in Amplihack:

# Integrate MCP tools into Amplihack workflow
from claude_agents.mcp import MCPClient

mcp_client = MCPClient("npx", ["-y", "@modelcontextprotocol/server-github"])

agent = Agent(
    model="claude-sonnet-4-5-20250929",
    mcp_clients=[mcp_client]
)

# Agent can now use GitHub MCP tools
result = agent.run("Create a GitHub issue for the bug we just found")

Hooks for Amplihack Observability:

# Log all agent actions to Amplihack runtime logs
class AmplihackLoggingHook(PreToolUseHook):
    async def execute(self, context):
        log_to_amplihack_runtime(
            session_id=get_current_session(),
            tool=context.tool_name,
            input=context.tool_input
        )
        return context

Quick Reference

Essential Commands

# Basic agent
agent = Agent(model="claude-sonnet-4-5-20250929")
result = agent.run("task")

# With tools
agent = Agent(model="...", tools=[tool1, tool2])

# With permissions
agent = Agent(model="...", allowed_tools=["tool1"])

# With hooks
agent = Agent(model="...", hooks=[LogHook()])

# Subagent
with agent.subagent(system="...") as sub:
    result = sub.run("subtask")

# MCP integration
from claude_agents.mcp import MCPClient
mcp = MCPClient("npx", ["-y", "mcp-server-name"])
agent = Agent(model="...", mcp_clients=[mcp])

Common Tool Patterns

# File operations
tools=["read_file", "write_file", "glob"]

# Code execution
tools=["bash"]

# All built-in
tools=["bash", "read_file", "write_file", "edit_file", "glob", "grep"]

Token Budget Recommendations

  • Simple tasks: 4K-8K tokens
  • Complex tasks: 16K-32K tokens
  • Research/analysis: 64K-128K tokens
  • Maximum context: 200K tokens (model dependent)

Next Steps

  1. Start Simple: Create a basic agent with built-in tools
  2. Add Custom Tools: Implement tools for your specific domain
  3. Add Hooks: Implement logging and validation
  4. Use Subagents: Delegate specialized tasks
  5. Integrate MCP: Use standardized tool servers
  6. Optimize: Tune context, permissions, and verification patterns

For complete API details, see reference.md. For working code, see examples.md. For production patterns, see patterns.md.

平台分布

Codex

37.52%
按下载量换算262

Claude

31.3%
按下载量换算218

Cursor

16.17%
按下载量换算113

Gemini CLI

8.44%
按下载量换算59

安全审计

Gen Agent Trust Hub

可疑

Socket

可疑

Snyk

可疑

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills