You send a message Claude responds You do all the work
→ Advice on the phone
Agent SDK
You define the mission Claude runs tools Agent does the work
→ Hired to do the job
The SDK gives Claude hands — not just a voice.
You have probably used Claude through a chat interface. You type a question, Claude answers. Maybe you paste in some code and ask for help. That is powerful, but it is also limited. You are the one doing the work — copying, pasting, running, checking. Claude is just thinking. You are the hands.
The Claude Agent SDK flips that equation. Instead of chatting with Claude, you build software that gives Claude hands. An agent built with the SDK can read files, write code, search the web, query databases, call APIs, run terminal commands, and make decisions — all on its own. You define the mission. The agent executes it.
This is the difference between asking a coworker for advice and hiring someone to do the job. The API is the advice line. The Agent SDK is the hiring contract.
Real-world analogy: Think of the Claude API like calling a brilliant friend on the phone — they can advise you, but they cannot reach through the phone to fix your car. The Agent SDK gives that friend a body. Now they can walk into your garage, pick up tools, diagnose the problem, order parts, and fix it while you do something else.
What the API Can Do (and Where It Stops)
The Claude API lets you send messages and get responses. You can set system prompts, control temperature, and even define tools for function calling. That is enough to build chatbots, content generators, and simple automations. But the API puts you in charge of every decision:
With the API alone, YOU must:
Write the tool execution loop. Handle every tool result. Manage conversation history. Decide when to stop. Implement permission checks. Handle streaming. Manage sessions. Build retry logic. Track costs. You are building the agent framework from scratch — every time.
With the Agent SDK, you get:
A complete agent runtime out of the box. Built-in tools (Bash, file operations, search). Automatic tool execution loops. Streaming event system. Session management with persistence. Permission controls. Cost guardrails. Sub-agent delegation. MCP server integration. You focus on what your agent does — not how agents work.
What the Agent SDK Unlocks
The SDK is not just convenience. It enables patterns that would take thousands of lines of custom code to build yourself:
1
Autonomous execution
Claude runs tools, reads results, decides next steps, and keeps going until the job is done. No human in the loop unless you want one.
2
Multi-agent delegation
Your main agent can spin up specialized sub-agents for specific tasks — a researcher, a coder, a reviewer — each with their own tools and instructions.
3
Session persistence
Agents can remember conversations across restarts. Resume where you left off, fork sessions for parallel exploration, and build agents that learn over time.
4
Safety guardrails
Built-in permission modes, cost budgets, turn limits, and lifecycle hooks let you control exactly what your agent can do — and stop it when it should not.
Your First Look at the SDK
Here is the simplest possible agent. This is not production code — it is the "Hello World" that shows you the shape of things to come:
TypeScript — your first agent in 5 lines
import { Claude } from"@anthropic-ai/claude-agent";
// Create a Claude agent with built-in toolsconst agent = new Claude({
model: "claude-sonnet-4-6", // which model powers the agent
tools: "defaults", // gives Claude file tools, bash, etc.
});
// Give the agent a task and let it workconst result = await agent.query(
"Read the file package.json and tell me what dependencies are installed."
);
console.log(result.text);
// Claude reads the file, parses it, and responds with a summary// — all without you writing any file-reading code
Notice what you did not write: no file reading code, no JSON parsing, no tool execution loop, no error handling for missing files. The SDK handles all of that. You described what you wanted. The agent figured out how to do it.
Who Should Use the Agent SDK
The Agent SDK is for anyone building AI-powered software that needs to act, not just respond. That includes:
Developers building
Coding assistants, deployment bots, data pipelines, research agents, customer service automation, internal tools, CI/CD integrations, content generation systems
Prerequisites
Comfortable with TypeScript or JavaScript. Familiar with npm. Basic understanding of async/await. No prior AI experience needed — this course teaches the rest.
What You Will Build in This Course
By the end of these 10 lessons, you will go from zero to deploying production agents. Here is the roadmap:
1-2
Install, authenticate, and make your first query
3-5
Master streaming, tool use, and MCP integration
6-8
Sub-agents, session management, hooks and lifecycle
9-10
Testing, safety, and production deployment
Agent SDK Foundations
What is the Claude Agent SDK?
A software development kit that lets you build AI agents that can autonomously execute tasks using tools like Bash, file operations, and MCP servers. Unlike the raw API (which just sends/receives messages), the SDK provides the full agent runtime.
API vs. Agent SDK
The API is a request/response interface — you send a message, get an answer. The Agent SDK is an agent framework — you define a mission, and Claude executes it using tools, making decisions along the way until the task is complete.
What are built-in tools?
The SDK ships with pre-built tools: Bash (run terminal commands), Read/Write/Edit (file operations), Grep/Glob (search). These give the agent hands — the ability to interact with the file system and operating environment.
What is autonomous execution?
The agent runs a tool loop automatically: call a tool, read the result, decide the next action, repeat until done. No human needs to approve each step (unless you configure it that way with permission modes).
What is sub-agent delegation?
A main agent can create specialized child agents for specific tasks. Each sub-agent gets its own tools, instructions, and context. The parent coordinates. Think: a manager delegating to specialists.
What is session persistence?
Agents can save conversation state and resume later. This enables long-running tasks, multi-session workflows, and agents that remember previous interactions across restarts.
What prerequisites do I need?
Comfort with TypeScript/JavaScript, familiarity with npm, and understanding of async/await. No prior AI or machine learning experience needed — this course covers everything else.
Why Agent SDK — Comprehension Check
1What is the main difference between the Claude API and the Claude Agent SDK?
Explanation: The API is a message-in, message-out interface. The Agent SDK provides a complete agent runtime with built-in tools, automatic tool execution loops, session management, and more — enabling Claude to act autonomously.
2Which of these tasks would benefit MOST from the Agent SDK (vs. the raw API)?
Explanation: Analyzing a codebase requires reading multiple files, understanding relationships, making edits, and potentially running tests — a multi-step autonomous workflow. The SDK handles the tool loop, file operations, and decision-making. The other tasks are single-turn responses the API handles fine.
3What does the tools: "defaults" option give your agent?
Explanation: The defaults tools preset gives Claude access to file system operations (Read, Write, Edit), terminal commands (Bash), and search tools (Grep, Glob). These are the core capabilities that let an agent interact with your local environment.
4What is session persistence used for?
Explanation: Session persistence lets agents save their conversation state and resume later. This enables long-running workflows, multi-session tasks, and agents that remember previous interactions — critical for production agent systems.
5You want Claude to automatically read a log file, find errors, and write a summary report. Which approach is best?
Explanation: This is a multi-step autonomous task: read a file, analyze its contents, and write a new file. The Agent SDK handles this naturally — Claude uses Read to get the log, processes it, and uses Write to create the report. No manual copying or pasting needed.