# 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 the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## 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. --- ## Quick Use ```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: "Analyze this codebase and create a summary", workingDirectory: "./my-project", }); ``` --- ## Intro Claude Agent SDK is Anthropic's official TypeScript SDK, giving you the same tools, agent loop, and context management that power Claude Code. With 1,200+ GitHub stars, it lets you build autonomous agents that understand codebases, edit files, run commands, search the web, and execute multi-step workflows. Formerly the Claude Code SDK — renamed to reflect its broader use. Best for building custom AI agents that need filesystem access, command execution, and codebase understanding. Requirements: Node.js 18+, Anthropic API key. --- ## Core Features - Codebase understanding, file ops, command execution, web search, multi-step workflows, structured output, session management - Exposes the 53 tools Claude Code uses internally ### FAQ **Q: What is Claude Agent SDK?** A: Anthropic's official SDK that wraps Claude Code's full capabilities (file editing, command execution, codebase understanding) as a programmable API. **Q: Is it free?** A: The SDK is free to install; you pay for Anthropic API usage. --- ## Source & Thanks > 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/claude-agent-sdk-build-agents-claude-code-power-b6989234 Author: Anthropic