Command Palette

Search for a command to run...

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

claude-agent-sdk

БесплатноЗапускает вложенные скриптыНе проверен

Builds production-ready applications with the Claude Agent SDK for Python, covering orchestrators with subagents, programmatic agent configuration, hooks, and…

basher83от basher83★ 24 звезды на GitHub14 установок в других каталогах

Об этом скилле

Claude Agent SDK

Build production-ready applications using the Claude Agent SDK for Python.

SDK Version: This skill targets claude-agent-sdk>=0.1.6 (Python)

Overview

This skill provides patterns, examples, and best practices for building SDK applications that orchestrate Claude agents.

Quick Start

Copy the template and customize:

cp assets/sdk-template.py my-app.py
# Edit my-app.py - customize agents and workflow
chmod +x my-app.py
./my-app.py

The template includes proper uv script headers, agent definitions, and async patterns.

Choosing Between query() and ClaudeSDKClient

The SDK provides two ways to interact with Claude: the query() function for simple one-shot tasks, and ClaudeSDKClient for continuous conversations.

Quick Comparison

Feature query() ClaudeSDKClient
Conversation memory No - each call is independent Yes - maintains context across queries
Use case One-off tasks, single questions Multi-turn conversations, complex workflows
Complexity Simple - one function call More setup - context manager pattern
Hooks support No Yes
Custom tools No Yes
Interrupts No Yes - can interrupt ongoing operations
Session control New session each time Single persistent session

Important: Hooks and custom tools (SDK MCP servers) are only supported with ClaudeSDKClient, not with query(). If you need hooks or custom tools, you must use ClaudeSDKClient.

Note on Async Runtimes: The SDK works with both asyncio and anyio. The official SDK examples prefer anyio.run() for better async library compatibility, but asyncio.run() works equally well. Use whichever fits your project's async runtime.

When to Use query()

Use query() for simple, independent tasks where you don't need conversation history:

import anyio  # or: import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions

async def analyze_file():
    """One-shot file analysis - no conversation needed."""
    options = ClaudeAgentOptions(
        system_prompt="You are a code analyzer",
        allowed_tools=["Read", "Grep", "Glob"],
        permission_mode="acceptEdits"
    )

    async for message in query(
        prompt="Analyze /path/to/file.py for bugs",
        options=options
    ):
        print(message)

anyio.run(analyze_file)  # or: asyncio.run(analyze_file())

Best for:

  • Single analysis tasks
  • Independent file operations
  • Quick questions without follow-up
  • Scripts that run once and exit

Key limitation: Each query() call creates a new session with no memory of previous calls.

When to Use ClaudeSDKClient

Use ClaudeSDKClient when you need conversation context across multiple interactions:

import anyio  # or: import asyncio
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions, AssistantMessage, TextBlock

async def interactive_debugging():
    """Multi-turn debugging conversation with context."""
    options = ClaudeAgentOptions(
        system_prompt="You are a debugging assistant",
        allowed_tools=["Read", "Grep", "Bash"],
        permission_mode="acceptEdits"
    )

    async with ClaudeSDKClient(options=options) as client:
        # First query
        await client.query("Find all TODO comments in /path/to/project")
        async for message in client.receive_response():
            if isinstance(message, AssistantMessage):
                for block in message.content:
                    if isinstance(block, TextBlock):
                        print(f"Claude: {block.text}")

        # Follow-up - Claude remembers the TODOs found above
        await client.query("Now prioritize them by complexity")
        async for message in client.receive_response():
            if isinstance(message, AssistantMessage):
                for block in message.content:
                    if isinstance(block, TextBlock):
                        print(f"Claude: {block.text}")

        # Another follow-up - still in same conversation
        await client.query("Create a plan to address the top 3")
        async for message in client.receive_response():
            if isinstance(message, AssistantMessage):
                for block in message.content:
                    if isinstance(block, TextBlock):
                        print(f"Claude: {block.text}")

anyio.run(interactive_debugging)  # or: asyncio.run(interactive_debugging())

Best for:

  • Multi-turn conversations
  • Interactive workflows
  • Tasks requiring context from previous responses
  • Applications with interrupt capability
  • Orchestrators managing complex workflows

Key advantage: Claude remembers all previous queries and responses in the session.

See: examples/streaming_mode.py - Comprehensive ClaudeSDKClient examples with all patterns

Advanced: Interrupts with ClaudeSDKClient

Only `ClaudeSDK

Полный SKILL.md на GitHub

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

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

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

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

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

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

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

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

assets/sdk-template.pyassets/sdk-validation-checklist.mdexamples/agents.pyexamples/basic-orchestrator.pyexamples/hooks.pyexamples/mcp_calculator.pyexamples/plugin_example.pyexamples/quick_start.pyexamples/setting_sources.pyexamples/streaming_mode.pyexamples/system_prompt.pyexamples/tool_permission_callback.pyreferences/agent-patterns.mdreferences/api-reference.mdreferences/best-practices.mdreferences/custom-tools.mdreferences/hooks-guide.mdreferences/sessions.mdreferences/skills.mdreferences/slash-commands.mdreferences/subagents.mdreferences/system-prompts.mdreferences/tool-permissions.md

FAQ

Что делает скилл claude-agent-sdk?

Builds production-ready applications with the Claude Agent SDK for Python, covering orchestrators with subagents, programmatic agent configuration, hooks, and permissions.

Как установить скилл claude-agent-sdk?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл claude-agent-sdk запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

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

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