# 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. ## Install Save as a script file and run: ## Quick Use ```bash npm install @anthropic-ai/claude-agent-sdk ``` Basic usage: ```typescript 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) ```typescript // 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: ```typescript // 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](https://github.com/anthropics). Governed by Anthropic Commercial Terms. > > [claude-agent-sdk-typescript](https://github.com/anthropics/claude-agent-sdk-typescript) — ⭐ 1,200+ Thank you to Anthropic for making Claude Code's capabilities available as a programmable SDK. --- ## 快速使用 ```bash npm install @anthropic-ai/claude-agent-sdk ``` ```typescript import { Claude } from "@anthropic-ai/claude-agent-sdk"; const claude = new Claude({ apiKey: process.env.ANTHROPIC_API_KEY }); const result = await claude.agent({ prompt: "分析这个代码库并创建摘要", workingDirectory: "./my-project", }); ``` --- ## 简介 Claude Agent SDK 是 Anthropic 官方 TypeScript SDK,提供与 Claude Code 相同的工具、Agent 循环和上下文管理能力。拥有 1,200+ GitHub Star,可构建能理解代码库、编辑文件、运行命令、搜索网页和执行多步工作流的自主 Agent。原名 Claude Code SDK,重命名以反映更广泛用途。 适合人群:构建需要文件系统访问、命令执行和代码库理解的自定义 AI Agent。 依赖:Node.js 18+、Anthropic API Key。 --- ## 核心功能 - 代码库理解、文件操作、命令执行、网页搜索、多步工作流、结构化输出、会话管理 - 暴露 Claude Code 内部使用的 53 个工具 ### FAQ **Q: Claude Agent SDK 是什么?** A: Anthropic 官方 SDK,将 Claude Code 的全部能力(文件编辑、命令执行、代码库理解)封装为可编程 API。 **Q: 免费吗?** A: SDK 免费安装,按 Anthropic API 用量付费。 --- ## 来源与感谢 > Created by [Anthropic](https://github.com/anthropics). > > [claude-agent-sdk-typescript](https://github.com/anthropics/claude-agent-sdk-typescript) — ⭐ 1,200+ --- Source: https://tokrepo.com/en/workflows/b6989234-7835-4bd6-a182-f08f07d60d7c Author: Script Depot