Claude Agent SDK

Build production AI agents that autonomously read files, run commands, search the web, edit code, and accomplish complex goals. The same engine that powers Claude Code, available as a library.

Documentation

Understanding the Claude Agent SDK: From First Principles to Production

A comprehensive guide exploring the architecture, philosophy, and practical implementation of autonomous AI agents. Covers what distinguishes agents from workflows, why Anthropic embraced bash as a core tool, how the three-part agent loop works, and detailed explanations of both the TypeScript and Python SDKs.

23 min read ~5,000 words
Architecture Philosophy TypeScript Python Production

Building an Autonomous Worker Agent: From GitHub Issue to Verified Merge

A practical guide to building a production worker agent that handles the complete pull request lifecycle autonomously. Covers the gap in one-shot worker patterns, git worktree isolation for parallel agents, the review and merge loop, main branch verification, and modern Python tooling.

18 min read ~3,500 words
Worker Agent Python Git Worktrees GitHub CI/CD Production

Multi-Model Agents: Integrating Gemini Vision with Claude for Animation

A practical guide to building agents that combine Claude's orchestration with Gemini's vision capabilities. Demonstrates the pattern through a Roblox NPC animation workflow, covering command-line animation authoring in Blender, frame-by-frame visual analysis, runtime terrain adaptation with inverse kinematics, and Rojo-based development workflows.

18 min read ~3,900 words
Multi-Model Gemini Vision Animation Roblox MCP

Official Resources

SDK Documentation

Official documentation from Anthropic covering installation, configuration, and all SDK features.

Guides

In-depth guides for specific features and use cases.

Source Code and Examples

Official repositories and example implementations.

Key Concepts

What is an Agent?

An agent is fundamentally different from a workflow. Workflows follow your predetermined structure. Agents build their own structure. You give an agent a goal and the tools to achieve that goal, and it decides its own trajectory. Claude Code is the canonical example: you speak to it in natural language and it autonomously reads files, runs commands, edits code, and verifies its work.

The Three-Part Loop

Every well-designed agent follows this pattern: gather context (find the information needed for the task), take action (use appropriate tools), and verify the work (confirm the results are correct). If you can programmatically verify the agent's work, you have an excellent candidate for automation.

Bash Is All You Need

Anthropic discovered that the bash tool represents perhaps the most powerful capability you can give an agent. It enables storing results to files, dynamically generating scripts, composing functionality through pipes, and using any existing software on the system. This obviates the need for most specialized tools.

Defense in Depth

Security comes through multiple layers: model alignment training, harness permissioning and prompting, bash command parsing, and sandboxing. Each layer has holes, but the layers are arranged so no single path goes straight through. This is called the Swiss cheese defense.

Quick Start

Installation

Install Claude Code first (the SDK uses it as its runtime), then install the SDK package:

# Install Claude Code
curl -fsSL https://claude.ai/install.sh | bash

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

# Python
pip install claude-agent-sdk

Minimal Example

Create an agent that lists files in your directory:

# Python
import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions

async def main():
    async for message in query(
        prompt="What files are in this directory?",
        options=ClaudeAgentOptions(allowed_tools=["Bash", "Glob"])
    ):
        if hasattr(message, "result"):
            print(message.result)

asyncio.run(main())

Additional Reading