Chapter 1
What is the Agents SDK?
The Claude Agents SDK lets you build AI agents that can read files, write code, run commands, and complete complex tasks autonomously. Here's what it looks like:
agent.ts
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Find and fix the bug in auth.py",
options: { allowedTools: ["Read", "Edit", "Bash"] }
})) {
console.log(message);
}Click or hover over any part of the code to learn more
Hover over the code to explore each part
Natural Language
Describe tasks in plain English. No need to write complex logic—Claude figures out the steps.
Safe by Default
You explicitly grant permissions. Claude can only use tools you allow, keeping you in control.
Real-time Streaming
Watch the agent work in real-time. Every file read, edit, and command streams to you as it happens.