Command Palette

Search for a command to run...

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

TypeScript SDK Reference

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

Comprehensive reference for the TypeScript Agent SDK with functions, types, and interfaces for programmatic Claude Code interactions

CaptainCrouton89от CaptainCrouton89★ 493 звезды на GitHub22 установки в других каталогах

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

TypeScript SDK Reference

A comprehensive reference for building applications with the Anthropic Agent SDK (TypeScript), enabling programmatic interactions with Claude Code and custom tool integrations.

Installation

npm install @anthropic-ai/claude-agent-sdk

Quick Start

Core Functions

Function Purpose Key Use Case
query() Primary interface for Claude Code interactions Send prompts, stream responses, manage multi-turn conversations
tool() Define MCP tools with type-safe schemas Create custom tools for agents using Zod validation
createSdkMcpServer() Create in-process MCP servers Host tools natively in your application

Example: Basic Query

import { query } from '@anthropic-ai/claude-agent-sdk';

const result = query({
  prompt: "Analyze this code and suggest improvements",
  options: {
    allowedTools: ['Read', 'Grep'],
    model: 'claude-opus'
  }
});

for await (const message of result) {
  if (message.type === 'assistant') {
    console.log(message.message.content);
  }
}

Main Functions Reference

query()

Streams Claude Code responses with full message type support. Returns an async generator of SDKMessage objects.

Parameters:

  • prompt: string or async iterable of messages (streaming mode)
  • options: Configuration object (see Options below)

Returns: Query object (extends AsyncGenerator<SDKMessage, void>)

Key Methods:

  • .interrupt() – Interrupt streaming (streaming mode only)
  • .setPermissionMode(mode) – Change permissions dynamically (streaming mode only)

tool()

Creates type-safe MCP tool definitions using Zod schemas. Handlers receive validated inputs and must return CallToolResult.

Parameters:

  • name: Tool identifier
  • description: Natural language description
  • inputSchema: Zod schema defining inputs
  • handler: Async function (args: z.infer<Schema>, extra?: unknown) => Promise<CallToolResult>

Returns: SdkMcpToolDefinition<Schema>

createSdkMcpServer()

Creates an in-process MCP server for hosting custom tools. Runs in the same Node.js process—no subprocess overhead.

Parameters:

  • name: Server identifier
  • version: Optional semantic version
  • tools: Array of tool definitions from tool()

Returns: McpSdkServerConfigWithInstance (ready for mcpServers option)


Key Configuration Options

Essential Options

Option Type Default Purpose
allowedTools string[] All available Restrict which tools Claude can use
disallowedTools string[] [] Explicitly block tools
model string CLI default Override Claude model (e.g., 'claude-opus')
cwd string process.cwd() Working directory for operations
abortController AbortController New instance Control task cancellation

Advanced Options

Option Type Default Purpose
systemPrompt string or preset object None Custom system instructions or Claude Code preset
agents Record<string, AgentDefinition> undefined Programmatically define subagents with custom prompts
mcpServers Record<string, McpServerConfig> {} Connect stdio, SSE, HTTP, or SDK MCP servers
settingSources ('user' | 'project' | 'local')[] [] Load filesystem settings (CLAUDE.md, settings.json)
permissionMode PermissionMode 'default' 'default', 'acceptEdits', 'bypassPermissions', or 'plan'
maxThinkingTokens number undefined Token limit for extended thinking
maxTurns number undefined Maximum conversation turns before stopping
resume string undefined Resume a previous session by ID
forkSession boolean false Fork to new session on resume instead of continuing

Message Types Overview

The query() generator yields SDKMessage objects. Common types:

Message Type When Emitted Key Fields
'system' Session initialization tools, model, permissionMode, slash_commands
'user' User input sent message (APIUserMessage), uuid
'assistant' Claude responds message (APIAssistantMessage with content/tool_use)
'result' Query completes subtype ('success' or error), usage, total_cost_usd
'stream_event' Partial streaming data event (only if includePartialMessages: true)

See Message Types Reference for complete definitions.


Types Reference Overview

Core Configuration Types

  • Options – Query configuration with 20+ properties (Tools, MCP, permissions, execution)
  • PermissionMode – Control execution permissions: 'default', 'acceptEdits', 'bypassPermissions', 'plan'
Полный SKILL.md на GitHub

Установить TypeScript SDK Reference в Claude Code и Claude Desktop

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

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

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

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

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

Read
Write
Edit
Task

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

MESSAGE_TYPES.mdTOOLS.mdTYPES.md

FAQ

Что делает скилл TypeScript SDK Reference?

Comprehensive reference for the TypeScript Agent SDK with functions, types, and interfaces for programmatic Claude Code interactions

Как установить скилл TypeScript SDK Reference?

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

Скилл TypeScript SDK Reference запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить TypeScript SDK Reference с