Install
npm install @anthropic-ai/claude-agent-sdk@0.3.326 zodClaude Code as a TypeScript library — built-in tools, MCP, subagents, hooks, permissions and resumable sessions for Node.js.
Claude Code as a library for Node.js. query() gives TypeScript code the agent loop, built-in tools, permission system and sessions that power Claude Code, with custom tools defined in Zod.
Install
npm install @anthropic-ai/claude-agent-sdk@0.3.326 zodVersion
Current release: @anthropic-ai/claude-agent-sdk 0.3.326 · Node 18.14+ · ESM · checked 2026-11-19
Best for
Node services and tools whose agents read and change files, run commands and call MCP tools.
Most releases track Claude Code and leave the API alone. The ones that matter:
BUILTIN_TOOL_NAMES / LEGACY_TOOL_NAME_ALIASES exports; per-tool permission policies on SDK MCP servers.@anthropic-ai/claude-agent-sdk/core, a smaller entry point for bundled apps.verbatimPrompts: prompts are delivered literally, with no @file expansion or slash commands.permissionPrompts: 'none' for unattended sessions.getContextUsage({ detail: 'summary' }).resumeDropsTurn for safe truncating resume.unstable_v2_* session API removed; MCP servers connect in the background; Task tools replace TodoWrite.Full list: the upstream CHANGELOG.
There is no Agent class. query() is the entry point; it returns an async generator of typed messages.
import { query } from '@anthropic-ai/claude-agent-sdk';
for await (const message of query({ prompt: 'What is 15 + 27?', options: { model: 'claude-opus-5-5', systemPrompt: 'You are a helpful assistant.', },})) { if (message.type === 'result' && message.subtype === 'success') { console.log(message.result); }}Ready? Start Zero → Hero step 1 →
| Date | Version | Summary |
|---|---|---|
| 2026-11-17 | 0.3.326 | Bumped from 0.3.322 (0.3.323 to 0.3.326). Documented archiveSession()/unarchiveSession(), the mcpServersDelivery option (the default 'argv' is deprecated) and the new autoAllowBashIfSandboxed default of false. New snippets type-checked with tsc --strict. |
| 2026-10-25 | 0.3.310 | Bumped from 0.3.306 (0.3.307 to 0.3.310, released 2026-10-21 to 2026-10-23). Type changes are additive and optional (connectorId in SDK MCP server settings, liveReply on control requests, supportedDialogKinds and sshHostCommands in the bridge and settings types); the bundled Claude Code CLI moved from 2.1.306 to 2.1.310. Every code block that imports the SDK was re-checked with tsc --strict against 0.3.310: no SDK-related errors. No API changes to document. |
| 2026-10-25 | 0.3.306 | Audit against the installed package: added hook patterns (input rewriting, prompt screening, Stop hook) and a skills, slash commands and plugins section; all code type-checked with tsc --strict. |
| 2026-10-21 | 0.3.306 | Failure handling corrected: the iterator throws after yielding an error result, so run(), runResilient() and the router now capture the result and decide from is_error, subtype and api_error_status (tested against a stub executable). Fixed usage vs modelUsage, updatedToolOutput redaction in the middleware page and the Dockerfiles’ missing build stage. Added user input and approvals, image prompts, a SQLite SessionStore, a testing recipe and hosting patterns; rewrote the diagrams page. |
| 2026-10-21 | 0.3.306 | Guide rewritten and every code block type-checked (strict mode) against the installed package: fixed message.message.content, removed invented options (workingDirectory, temperature, maxTokens, apiKey) and message types (tool_call, tool_result, error), rewrote the middleware, multi-agent and Express pages around the Agent SDK instead of the base API client, added 0.3.142 migration notes, updated models to the Claude 5 family. |
| 2026-05-19 | 0.3.144 | 0.2.x → 0.3.x series (breaking changes in 0.3.142). |
| 2026-04-21 | 0.2.116 | Removed a fictional new Agent(...) constructor from the overview. |
| 2025 | 0.1.0 | Renamed from the SDK in @anthropic-ai/claude-code to @anthropic-ai/claude-agent-sdk. |
Note: the Python package has its own guide: Claude Agent SDK (Python).