Command Palette

Search for a command to run...

Назад к скиллам
скилл № 19378

claude-agent-sdk

Decisions, patterns and pitfalls for building agents with the Claude Agent SDK (TypeScript package @anthropic-ai/claude-agent-sdk, Python package…

БесплатноЗапускает вложенные скрипты
fcsouzaот fcsouza★ 29 звёзд на GitHub

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

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

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

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

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

Claude Agent SDK

The SDK runs the Claude Code binary as a subprocess and talks to it over stdio. Your code configures it and reads a stream of messages. Versions checked on 2026-11-15: @anthropic-ai/claude-agent-sdk 0.3.325, claude-agent-sdk 0.2.182 (Python 3.10+; Node 18.14+).

Use the official docs for the API

For the Messages API, use the claude-api skill if it is installed. For this SDK there is no official skill, so read the docs. Fetch the index at https://code.claude.com/docs/llms.txt and open the Agent SDK pages as .md. Start with these:

Do not copy option tables, hook-event lists or type definitions into answers from memory. They change with each release. Open the page, then quote the field name.

Pick the runtime first

  • Agent SDK: your process runs Claude Code's loop, tools, permissions and sessions. Use it for coding agents, CI agents and file-and-shell work.
  • Client SDK (Messages API): you write the tool loop yourself. Use it when you need no built-in file or shell tools.
  • Managed Agents: Anthropic hosts the loop and the sandbox. Use it when you do not want to operate containers.
  • Another language: run claude -p --output-format json as a subprocess.

Entry points

  • query() starts a new session on every call. Use it for one-off and CI tasks. For multi-turn in TypeScript, pass an AsyncIterable of user messages as prompt, or pass continue: true / resume: sessionId.
  • ClaudeSDKClient (Python) keeps one session across client.query() calls and supports interrupt().
  • The TypeScript V2 session API (unstable_v2_*) was removed in 0.3.142. Do not use it. Use query().
  • Always branch on ResultMessage.subtype before reading result. success is the only subtype that carries a final answer. The others are error_max_turns, error_max_budget_usd, error_during_execution and error_max_structured_output_retries.

Copy templates/ci-agent.ts (TypeScript) or templates/agent.py (Python) when you need a headless agent with caps and a result check.

Permissions

The SDK checks every tool call in six steps. The first step that decides wins:

  1. Hooks. A hook can deny or pass. A hook that returns allow does not skip steps 2 and 3.
  2. Deny rules (disallowedTools, and deny rules from loaded settings files). They deny in every mode, bypassPermissions included.
  3. Ask rules (from settings.json). A match goes to canUseTool, even in bypassPermissions.
  4. Permission mode.
  5. Allow rules (allowedTools, allow rules from settings). Safe reads inside the working directory also resolve here.
  6. canUseTool callback. In dontAsk mode this step is skipped and the call is denied.

What follows from that order:

  • allowedTools approves the tools it lists. It does not restrict Claude to them. Unlisted tools fall through to the mode and canUseTool. To remove a tool, use disallowedTools. A bare tool name there removes the tool definition. A pattern like Bash(rm *) keeps Bash and denies matching calls.
  • An allow rule for a tool name hides that tool's calls from canUseTool. If your callback must see them, remove the name from allowedTools. The SDK warns with code CLAUDE_SDK_CAN_USE_TOOL_SHADOWED for this and for bypassPermissions.
  • For headless agents use dontAsk with an explicit allowedTools. A call that would need approval is then denied instead of waiting for a prompt that nobody answers. Calls that need no approval in default mode still run: reads in the working directory, read-only Bash commands, and others the permissions page lists. Add disallowedTools for anything that must never run.
  • `bypa
Полный SKILL.md на GitHub

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

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

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

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

  • references/bun-runtime.md
  • references/sources.md
  • templates/agent.py
  • templates/bun-compile.ts
  • templates/ci-agent.ts
  • templates/embedded-binary.d.ts
  • templates/guard-hook.ts
  • templates/subagents.ts
  • templates/tenant-isolation.ts

FAQ

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

Decisions, patterns and pitfalls for building agents with the Claude Agent SDK (TypeScript package @anthropic-ai/claude-agent-sdk, Python package claude-agent-sdk): permissions, settings isolation, subagents, hooks, custom tools, sessions, hosting. Use when writing or reviewing code that calls the SDK's query() or ClaudeSDKClient, or when deciding how to run, secure, cap or host such an agent.

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

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

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

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

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

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