ScriptsApr 6, 2026·3 min read

Claude Agent SDK — Build Agents with Claude Code Power

Anthropic's official TypeScript SDK for building AI agents with Claude Code's full capabilities — file editing, command execution, codebase understanding, and complex workflows. npm package.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

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

Basic usage:

import { Claude } from "@anthropic-ai/claude-agent-sdk";

const claude = new Claude({ apiKey: process.env.ANTHROPIC_API_KEY });

const result = await claude.agent({
  prompt: "Analyze this codebase and create a summary",
  workingDirectory: "./my-project",
});

console.log(result.output);

Requires: Node.js 18+ and an Anthropic API key.


Intro

The Claude Agent SDK is Anthropic's official TypeScript SDK that gives you the same tools, agent loop, and context management that power Claude Code — now programmable in your own applications. With 1,200+ GitHub stars, it enables building autonomous agents that understand codebases, edit files, run shell commands, search the web, and execute multi-step workflows. Formerly known as the Claude Code SDK, it was renamed to reflect its broader purpose: building agents that go beyond coding — email assistants, research agents, customer support bots, and more.

Best for: developers building custom AI agents that need file system access, command execution, and codebase understanding. Works with: Node.js 18+, Bun, Anthropic API. Setup time: under 2 minutes.


Claude Agent SDK — Features & API

Core Capabilities

Capability Description
Codebase Understanding Analyze and comprehend entire project structures
File Operations Read, write, create, and edit files programmatically
Command Execution Run shell commands within agent workflows
Web Search Search the internet for information
Multi-Step Workflows Chain complex autonomous tasks
Structured Outputs Return validated JSON matching your schema
Session Management V2 APIs for multi-turn conversations

V2 Session API (New)

// Create a persistent session
const session = await claude.unstable_v2_createSession({
  workingDirectory: "./project",
});

// Send messages within the session
const response = await claude.unstable_v2_prompt(session.id, {
  prompt: "What files are in this project?",
});

// Continue the conversation
const followUp = await claude.unstable_v2_prompt(session.id, {
  prompt: "Now refactor the main module",
});

Available Tools

The SDK exposes the same 53 tools that Claude Code uses internally:

  • File tools: Read, Write, Edit, Glob, Grep
  • Shell tools: Bash command execution
  • Search tools: Web search, web fetch
  • Agent tools: Spawn sub-agents for parallel tasks
  • Planning tools: Task decomposition and approval

Use Cases

  1. Custom Coding Agents — Build your own Claude Code with custom behaviors
  2. Email Assistants — Agents that read, classify, and respond to emails
  3. Research Agents — Multi-agent systems that search, analyze, and synthesize
  4. CI/CD Agents — Autonomous code review and fix workflows
  5. Document Processors — Analyze and transform documents at scale

Migration from Claude Code SDK

The package was renamed from @anthropic-ai/claude-code-sdk to @anthropic-ai/claude-agent-sdk. Update your import:

// Old
import { Claude } from "@anthropic-ai/claude-code-sdk";
// New
import { Claude } from "@anthropic-ai/claude-agent-sdk";

FAQ

Q: What is the Claude Agent SDK? A: Anthropic's official TypeScript SDK that provides the same capabilities as Claude Code (file editing, command execution, codebase understanding) in a programmable API for building custom AI agents.

Q: Is it free? A: The SDK is free to install. You pay for Anthropic API usage (Claude model tokens). Governed by Anthropic's Commercial Terms of Service.

Q: How is this different from the regular Anthropic SDK? A: The regular SDK (@anthropic-ai/sdk) sends messages to Claude models. The Agent SDK adds the full agent loop — tool execution, file system access, shell commands, and multi-step autonomous workflows.


🙏

Source & Thanks

Created by Anthropic. Governed by Anthropic Commercial Terms.

claude-agent-sdk-typescript — ⭐ 1,200+

Thank you to Anthropic for making Claude Code's capabilities available as a programmable SDK.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets