The Agent SDK
This one’s for people who write code. If that’s not you, skim it for the idea — “you can build your own Claude-powered tools” — and move on. Nothing in the rest of the level depends on it.
Headless mode (Lesson 11.6) let you use Claude as a command. The Agent SDK lets you build with it — wrap your own program around the same engine that runs Claude Code.
The Claude Agent SDK is a toolkit (for TypeScript or Python) that gives your own code the full Claude Code engine: the agent loop, tools, MCP, hooks, subagents — all of it, as a library you call.
In Python it’s about this small:
from claude_agent_sdk import query
async for message in query(prompt="Find and fix the failing test in this repo"):
print(message)
That handful of lines spins up an agent that reads files, runs commands, fixes the test, and reports back — the same loop you’ve been driving by hand all course, now inside your program.
The distinction that matters: API vs. SDK
If you’ve touched AI before, you’ve probably used the Anthropic API directly — the raw line to the model. That’s a great tool, but it’s a single exchange: you send messages, you get one reply. If you want the model to actually run a command, read the result, and decide what to do next, you have to build that whole loop — call the tool, feed the output back, ask again, repeat, handle errors. That loop is most of the hard work in any agent.
The raw API gives you the brain. The Agent SDK gives you the brain plus the body — the loop, the tools, the permission system, the context management — already built and battle-tested.
Put simply:
| You want… | Reach for… |
|---|---|
| One question, one answer (classify this, summarize that) | the raw Anthropic API |
| A thing that works agentically — explores, runs tools, iterates | the Agent SDK |
The SDK is, almost literally, Claude Code with the front door removed so you can wire your own thing onto the same room.
What people build with it
- A custom reviewer embedded in their own platform that reads a diff and posts findings.
- A support agent that reads a customer ticket, digs through the codebase, and drafts a fix.
- A migration tool that walks a hundred repos and applies the same change to each.
The thread: a repeatable, agentic job too shaped-to-your-needs for a plain claude -p, and too involved to babysit by hand.
Where headless ends and the SDK begins
It’s a spectrum, not a wall:
- A one-off task in a script → headless mode. Don’t reach for the SDK.
- A real program where the agent is a component — custom tools, your own UI, branching logic → the SDK.
Most people never need the SDK, and that’s fine. But when you’ve outgrown one-shot commands and want Claude’s full intelligence inside something you’re building, this is the door — and it’s the same engine you already trust.
What’s next
So far, you still kick everything off — a prompt, a command, a script you run. The last two lessons remove even that. Scheduled agents let Claude start itself, on a clock, while you’re nowhere near the keyboard.