or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

apis

agents.mdhooks.mdmcp.mdmessages.mdoptions.mdpermissions.mdquery-api.mdsandbox.mdtools.md
index.mdpatterns.mdquick-reference.mdtypes.md
tile.json

tessl/npm-anthropic-ai--claude-agent-sdk

SDK for building AI agents with Claude Code's capabilities to programmatically interact with Claude and build autonomous agents that can understand codebases, edit files, and execute workflows.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@anthropic-ai/claude-agent-sdk@0.1.x

To install, run

npx @tessl/cli install tessl/npm-anthropic-ai--claude-agent-sdk@0.1.0

index.mddocs/

Claude Agent SDK

Package: @anthropic-ai/claude-agent-sdk (npm) Language: TypeScript Install: npm install @anthropic-ai/claude-agent-sdk Requires: Node.js 18+, Zod ^3.24.1

Build AI agents with Claude Code's capabilities: understand codebases, edit files, run commands, execute workflows.

Quick Start

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

const result = query({
  prompt: 'List all TypeScript files',
  options: {
    model: 'claude-sonnet-4-5-20250929',
    cwd: '/path/to/project'
  }
});

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

Core APIs

APIPurposeDoc
query()Main API for agent queriesquery-api
unstable_v2_createSession()Persistent sessions (experimental)query-api
OptionsConfiguration interfaceoptions
Message typesType-safe message systemmessages
PermissionsControl tool executionpermissions
HooksLifecycle interceptorshooks
MCPCustom tools & serversmcp
AgentsCustom subagentsagents
SandboxSecure executionsandbox
Built-in toolsFile ops, shell, webtools

Essential Types

// Core imports
import {
  query,
  type Options,
  type Query,
  type SDKMessage,
  type SDKResultMessage,
  type AgentDefinition,
  type PermissionResult,
  type HookCallback
} from '@anthropic-ai/claude-agent-sdk';

// V2 API (unstable)
import {
  unstable_v2_createSession,
  unstable_v2_resumeSession,
  unstable_v2_prompt,
  type SDKSession
} from '@anthropic-ai/claude-agent-sdk';

// MCP tools
import {
  createSdkMcpServer,
  tool,
  type McpServerConfig
} from '@anthropic-ai/claude-agent-sdk';

Common Patterns

See patterns.md for:

  • File operations workflow
  • Multi-turn conversations
  • Custom permission handlers
  • Hook-based logging
  • MCP tool creation
  • Subagent orchestration

Type Reference

Complete type definitions: types.md

Quick Reference

All APIs at a glance: quick-reference.md