← 返回
未分类

Claude Code Agent SDK

Claude Agent SDK documentation — build production AI agents with Claude Code as a library in Python or TypeScript. Use when building, configuring, or debuggi...
Claude Agent SDK 文档 — 使用 Python 或 TypeScript 将 Claude Code 作为库构建生产级 AI 代理。适用于构建、配置或调试。
openlark openlark 来源
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 254
下载
💾 0
安装
1
版本
#latest

概述

Claude Code Agent SDK

Build production-grade AI agents using Claude Code as a library. Supports Python and TypeScript.

Covers

  • Quickstart and setup
  • Agent loop and message types
  • Tool configuration and built-in tools
  • Hooks for intercepting agent behavior
  • Session management (resume, fork, continue)
  • MCP server integration
  • Sub-agents and parallel execution
  • Permissions and security
  • Custom tools
  • Streaming and structured outputs
  • Cost tracking and observability
  • Claude Code features (skills, commands, memory)
  • Hosting and deployment
  • Python and TypeScript API references.

Quick Navigation

Reference files are split by topic in references/. Load only what you need:

Core

  • overview.md — SDK overview, installation, authentication, built-in tools, permission modes
  • quickstart.md — Quick start: building a bug fix agent
  • agent-loop.md — Agent loop: message types, tool execution, context window, compression

Agent Control

  • hooks.md — Hooks: PreToolUse/PostToolUse/Stop, matchers, callback functions
  • permissions.md — Permissions: allowedTools/disallowedTools, permission modes
  • user-input.md — User input: approval prompts, AskUserQuestion

Sessions & State

Tools & Integration

  • custom-tools.md — Custom tools: in-process MCP server
  • mcp.md — MCP: connect external tools + tool search extending to thousands of tools

Sub-agents & Parallelism

  • subagents.md — Sub-agents: AgentDefinition, context isolation, parallel tasks + todo tracking

Streaming & Output

  • streaming-output.md — Streaming responses + input schemas + structured outputs (JSON Schema/Zod/Pydantic)

Configuration & Features

Operations

API Reference

  • python.md — Python SDK API reference
  • typescript.md — TypeScript SDK API reference (includes V2 deprecation notes)

Key Patterns

Basic agent

from claude_agent_sdk import query, ClaudeAgentOptions

async for message in query(
    prompt="Fix the bug in auth.py",
    options=ClaudeAgentOptions(allowed_tools=["Read", "Edit", "Bash"])
):
    print(message)

With hooks

options = ClaudeAgentOptions(
    hooks={"PreToolUse": [HookMatcher(matcher="Bash", hooks=[validate_command])]}
)

With MCP servers

options = ClaudeAgentOptions(
    mcp_servers={"playwright": {"command": "npx", "args": ["@playwright/mcp@latest"]}}
)

With sub-agents

options = ClaudeAgentOptions(
    allowed_tools=["Read", "Glob", "Agent"],
    agents={"reviewer": AgentDefinition(
        description="Code reviewer",
        prompt="Review code quality",
        tools=["Read", "Glob", "Grep"]
    )}
)

Multi-turn with sessions

async with ClaudeSDKClient(options=options) as client:
    await client.query("Analyze the auth module")
    async for msg in client.receive_response(): print(msg)
    await client.query("Now refactor it")  # auto-continues
    async for msg in client.receive_response(): print(msg)

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-21 15:54 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,403 📥 324,092
content-creation

Toutiao Graphic Publisher

openlark
通过浏览器自动化在头条发布图文内容,支持智能排版、自动生成热门标签等功能。
★ 2 📥 1,008
ai-agent

Find Skills

guipi888
场景驱动+关键词双模式技能发现工具。当用户用自然语言描述场景/需求(如"我想做一个海报""帮我分析股票"),或明确说"安装技能/find skills/找个skill"时,自动从官方内置、本地已安装、SkillHub、虾评、GitHub、C
★ 1,486 📥 550,063