
A warm welcome to the course. Discover what the Claude Agent SDK is, preview the three complete agents you will build, and understand why autonomous AI agents are a skill worth learning right now.
Learn what the SDK is, what makes it different from the raw Anthropic API, and how it compares to Claude.ai, the Client SDK, and Managed Agents.
Meet the four components — your Python code, the SDK relay, Claude the reasoner, and Claude Code the executor — and understand the THINKING vs DOING distinction.
A detailed walkthrough of the 10-step agent loop, the five message types you will see in your code, and why understanding this loop makes you a better agent developer.
A quick orientation to the course resources. Learn how to find Colab notebook links in the Resources, understand the difference between Starter and Solution notebooks, and see how each notebook is structured — self-contained setup cells, inline comments, and markdown cells that guide you through the code
Get your coding environment ready in minutes. Set up Google Colab, add your Anthropic API key to Colab Secrets, install the SDK, and verify everything is working.
Write your first autonomous agent. Learn async/await in Python and run your first query() call in Google Colab.
Learn the four message types in the agent stream — SystemMessage, AssistantMessage, UserMessage, and ResultMessage — and extract the final result cleanly.
Build your first complete agent from scratch. The File Explorer Agent explores a directory, reads every file, and produces a clean summary report.
A calm walkthrough of every common error beginners hit — API key issues, SDK not installed, runtime restarts, asyncio errors, and invalid model names.
A focused deep dive into the three core file tools. Learn what each one does, when to use it, and the critical difference between Write and Edit.
Give your agent terminal superpowers. Learn how Bash runs any shell command and how Monitor watches a live process and reacts to output line by line in real time.
Teach your agent to find things. Glob finds files by pattern, Grep searches inside files with regex. Includes a beginner-friendly regex introduction and a combined demo.
Your agent goes live on the internet for the first time. WebSearch finds current information, WebFetch retrieves full page content. Includes a combined research workflow demo.
Build human-in-the-loop agents that pause mid-task and ask clarifying questions. Includes the complete HTTP connection, streaming input, and keep-alive mechanism explained clearly.
The Section 3 payoff. A multi-tool agent that searches a codebase for TODOs, asks the user how they want the report, and produces a clean prioritised summary.
Learn the complete 6-gate permission evaluation flowchart, the difference between allowed_tools and disallowed_tools, the five permission modes, and the bypassPermissions gotcha.
Build a read-only agent and two auto-edit configurations running the same task. See why multiple permission combinations can produce identical results through different gate paths.
Learn how PreToolUse hooks work and build automated blocking rules for dangerous Bash commands, sensitive path writes, and out-of-bounds file access — with live trigger demos.
The course capstone. A production-safe agent that reviews code for quality and security issues with three stacked layers of protection and human-in-the-loop interaction.
Hooks let your own Python code run at key moments in the agent loop, before a tool runs, after it returns, when a prompt is submitted, and more. In this lecture you learn which hook events the Python SDK supports, how a hook callback and a matcher fit together, and how a hook's response can allow, deny or change what the agent does.
After this lecture you will be able to choose the right hook event for a job and explain how hooks sit around the agent loop.
A PostToolUse hook runs after a tool finishes, which makes it the natural place to record what your agent actually did. In this hands-on lecture you write a hook callback, attach it to specific tools with a matcher, and log every tool call the agent makes.
After this lecture you will be able to build an activity log for any agent and read the tool name, input and response that a PostToolUse hook receives.
PostToolUse hooks can do more than watch. In this lecture you use one to change the output a tool returns, such as masking sensitive values before they go any further, and another to stop an agent run once a limit is reached. You also see what happens when a hook returns the wrong shape, and why you should always confirm results against the files on disk.
After this lecture you will be able to modify tool output from a hook and stop a run from a hook.
A UserPromptSubmit hook runs when a prompt is sent to the agent, before the agent starts working on it. In this lecture you use it to add extra context to a prompt, so the agent can answer questions that depend on information it was never given. You compare an agent with no hook against the same agent with context injected, and then make the injection conditional.
After this lecture you will be able to inject context into prompts and decide when a hook should add it.
In this capstone for the section you combine two hooks into one agent. A PreToolUse hook guards a protected folder, and a PostToolUse hook records every file the agent changes. You then check the results against the real files, so you do not have to trust the agent's own summary.
You code along in the starter notebook, and the solution notebook is there as a reference.
After this lecture you will be able to build an agent that blocks changes to protected files and keeps a reliable audit log of everything it changed.
Every time your agent runs, the SDK saves the conversation to a transcript file on disk. In this lecture you capture the session ID from a finished run, find the transcript, and look inside it. You also use the SDK’s session functions to list saved sessions, read their details and replay their messages.
After this lecture you will be able to explain what a session is, locate its transcript, and inspect saved sessions with the Python SDK.
A session is only useful if you can come back to it. In this lecture you capture a session ID, resume that exact conversation in a new run, and see the agent remember what it already learned. You then continue the most recent conversation without an ID, and use a client object for multi-turn conversations.
After this lecture you will be able to resume a past conversation by ID, continue the most recent one, and choose the right approach for your agent.
Sometimes you want to try a second idea without losing the first. Forking branches a session into a new one, so both conversations continue from the same starting point without affecting each other. In this lecture you fork a live session, prove the original is untouched, and then create a fork offline from a chosen message in the saved history.
After this lecture you will be able to fork a session, tell a fork apart from a resume, and branch from an earlier point in a conversation.
A session remembers the conversation, but it does not undo what the agent did to your files. File checkpointing does. In this lecture you turn it on, let the agent edit files, and rewind them to an earlier point. You confirm the result by checking the files on disk. You also see which changes checkpointing tracks and which it cannot, including a demo with shell commands.
After this lecture you will be able to enable file checkpointing, rewind an agent’s file changes, and know where its limits are.
Long conversations grow, and growth costs tokens and money. In this lecture you check how much of the context window a session is using and estimate what a run costs. You also see how a resumed session reports its spend, compact a conversation, and set limits on turns and budget so a run cannot get out of hand.
After this lecture you will be able to monitor context usage, read cost figures from a run, compact a long session, and put guardrails on an agent.
Put the whole section to work on one small Python project with a hidden bug. In a single session you analyse the code, fix the bug with file checkpointing on, rewind the fix and try a different one, and fork a read-only branch to double-check. You check progress with real test runs on disk and track context and cost as you go, then finish with a summary report.
After this lecture you will be able to combine sessions, resuming, forking, checkpointing and cost tracking in one multi-turn agent workflow.
An agent that does everything itself fills its context with every file and tool result it touches. Subagents fix that. In this lecture you learn what a subagent is, how the main agent hands it a task through the Agent tool, and what the subagent receives and returns. You also see the three ways to create subagents, how the main agent decides which one to use, and the common workflow patterns: parallel, sequential, routing, orchestrator and workers, and review loops.
After this lecture you will be able to explain how delegation works, when a subagent is worth using, and what it costs.
Meet the Bike Repair Co-op, a cooperative workshop run by volunteers, and its pile of 40 work orders. In this lecture the co-op’s agent hands the reading to the built-in general-purpose subagent. You spot the delegation in the message stream, see the prompt the main agent wrote for its helper, and see the single result that comes back. You then compare the main agent’s own token usage with the total cost of the run.
After this lecture you will be able to turn on delegation, recognise a subagent call in the stream, and explain what the main agent sees of a subagent’s work
The built-in subagent is a generalist. In this lecture you build your own specialists for the Bike Repair Co-op with AgentDefinition, each with its own description, instructions, tools and model. You see why its field names use camelCase and what happens if you forget. You let the main agent pick a specialist from its description, then name one in the prompt to make sure it is used. You restrict a specialist’s tools and prove on disk that the restriction holds. You also load an agent defined in a markdown file, the way teams share agents in a project.
After this lecture you will be able to define custom subagents, route work to them automatically or by name, limit what each one can do, and load agents from files.
When three subagents work on one request, their messages arrive in a single mixed stream. In this lecture the Bike Repair Co-op’s three specialists answer one request together, and you untangle the stream to see exactly who did what. You find every subagent call, group the stream by parent_tool_use_id, and match each specialist with the answer it sent back. You also read the task messages as a timeline of when each subagent started and finished, and turn on forwarded subagent text. Along the way you see why the same tool appears under two names, Agent and Task.
After this lecture you will be able to trace any subagent’s work in the message stream, connect each call to its result, and follow subagents as they run.
Specialists are most useful when they work together. In this lecture the Bike Repair Co-op’s three specialists produce a weekly briefing. Independent jobs run in parallel, and one specialist’s results are passed to the next in sequence. You check a timeline to see what actually ran when, and you confirm the finished briefing on disk. You also learn how to keep a specialist’s exact words in the final output, and how to resume a specialist so it can answer a follow-up question with its earlier work still in mind.
After this lecture you will be able to design parallel, sequential and mixed subagent workflows with goal prompts alone, pass data between specialists, and resume a subagent.
Subagents are powerful, so you need ways to keep them in check. In this lecture you put guardrails on the Bike Repair Co-op's specialists. Lifecycle hooks write a log entry every time a subagent starts or stops. A tool hook blocks one specialist from writing files while the main agent can still write, and you confirm the result on disk. You limit how many subagents run at once and how deep they can delegate, and you set a spending cap that stops a run and tells you why. Finally, you see where subagent cost appears in the results, and estimate a run's cost from the token counts.
After this lecture you will be able to monitor and control individual subagents with hooks, cap concurrency, depth and spend, and track what subagents cost.
Put the whole section to work on real code. The Bike Repair Co-op's small Python module has a hidden bug and no tests. You build a team of three specialists to handle it. An inspector reviews the code without changing it. A test writer creates pytest tests from the docstrings. A repair technician fixes the bug and reruns the tests until they pass. The review and the test writing run in parallel, the fix follows in sequence, and hooks log every agent and stop the fixer from editing the tests. Your own pytest run proves the fix worked, not the agents' report. You also check that the new tests fail on the original buggy code, then review what the pipeline cost.
After this lecture you will be able to design, guard and verify a multi-agent pipeline that finds, proves and fixes a real bug.
The built-in tools let an agent work with files, the shell and the web, but not with a team's bug tracker, database or other everyday systems. The Model Context Protocol (MCP) closes that gap. In this lecture you learn what MCP is, how servers offer tools to an agent, and what people build with it, from code review and debugging to project planning and design. You see the three ways to connect a server: tools inside your own program, a separate process on the same machine, and a remote server reached by URL. You also learn how MCP tools are named, approved and given credentials, and you meet Pixel Forge, the indie game studio used throughout this section.
After this lecture you will be able to explain how MCP works, choose the right way to connect a server, and approve its tools safely.
Turn a plain Python function into a tool your agent can call. In this lecture you take a game-balance calculation from Pixel Forge, the section's indie game studio, and wrap it with the tool decorator. You serve it from an in-process MCP server that runs inside the notebook, with nothing to install. You see the tool appear in the agent's tool list, approve it, and watch the agent call it for an exact answer, checked against the function itself. You then add a second tool to the same server and see what happens when a tool is visible to the agent but not approved.
After this lecture you will be able to define custom tools in Python, serve them through an in-process MCP server, and approve them by name or with a wildcard.
Custom tools become really useful when they work with your application's own data. In this lecture Pixel Forge's tools manage the studio's sprint board, which the agent can now read and change. You give a tool a stricter schema so it accepts only valid values, read optional arguments, and return clear error messages the agent can act on. You see the schema reject bad input before your function runs. You also mark read-only tools so the agent can call them side by side. Every change is checked against the board saved on disk, not the agent's own report.
After this lecture you will be able to build custom tools that read and change application data, validate their input with JSON Schema, and report errors the agent can respond to.
You don't have to write every tool yourself. In this lecture Pixel Forge's bug tracker lives in a SQLite database, and a ready-made MCP server gives the agent access to it. You connect the server over stdio by telling the SDK how to start it: a command, its arguments, and the settings it needs. The SDK runs it as a separate program for the length of the agent's run, and you prove it really is separate by comparing process IDs. The agent then reads, reports and closes bugs, and you check every change directly in the database. Along the way you see how a server's tools appear, how they are approved, and how a clear error reaches the agent.
After this lecture you will be able to connect a local MCP server over stdio, pass it settings through its environment, and use its tools from an agent.
Some MCP servers don't run on your machine at all. In this lecture Pixel Forge is deciding whether to use pygame, an open-source Python game library. The studio researches it through DeepWiki, a free remote MCP server that answers questions about public GitHub repositories. You connect it with nothing but a URL, check that it connected before relying on it, and watch the agent explore the repository and answer real questions about it. You see what you can verify about a remote answer and what you can't, and how servers that need an API key receive it through headers. Finally, one agent uses the remote server and a local custom tool together, recording its decision in a file you check on disk.
After this lecture you will be able to connect remote MCP servers over HTTP, check their connection, and combine remote and local tools in one agent.
Real agents often connect to several MCP servers at once, and things go wrong: a server is slow, a config is broken, or a tool is too risky to leave unguarded. In this lecture Pixel Forge's agent connects to three kinds of server together: in-process tools, a local stdio server and a remote HTTP server. You see every server and tool at a glance, check each server's live status, and watch one broken server fail without taking the others down. You switch a server off and on in the middle of a conversation, approve only the exact tools the agent needs, and use a hook to stop the agent closing critical bugs while everything else runs freely. Every result is checked against the database on disk.
After this lecture you will be able to inspect and monitor multiple MCP servers, control which tools an agent can use, and guard risky tools with hooks.
Explore Google's Agent Development Kit as a complementary course to Claude, offering a different ecosystem and tools for a broader, well-rounded understanding of modern agentic AI development.
AI agents are how software gets built next. This course teaches you to build them — from scratch, in Python, using the Claude Agent SDK.
The Claude Agent SDK is the same technology that powers Claude Code — Anthropic's AI coding assistant used by hundreds of thousands of developers worldwide. This course gives you programmatic access to that same engine, so you can build autonomous agents that read files, run commands, search the web, ask users questions, and complete complex multi-step tasks — without writing a single line of tool execution logic yourself.
What You Will Build
By the end of this course you will have built three complete agents from scratch:
File Explorer Agent — autonomously explores a directory, reads every file, and produces a clean summary report. Your first complete autonomous agent.
Codebase TODO Summarizer Agent — searches an entire codebase for TODO comments, filters results by priority based on your preferences, and produces a structured report. Uses Glob, Grep, Read, and AskUserQuestion working together.
Safe Code Review Agent — the course capstone. Reviews code for quality issues and security vulnerabilities — hardcoded credentials, SQL injection, poor error handling — without being able to modify a single file. Three layers of production safety built in.
What You Will Learn
Section 1 — The Big Picture
Understand exactly how the Claude Agent SDK works under the hood before writing a single line of code. The four components, the agent loop, pipe communication between the SDK and Claude Code, and session management. This mental model makes everything else in the course click.
Section 2 — Your First Agent
Everything runs in Google Colab — no local setup required. Write your first query() call, master async/await in Python, read and filter the agent message stream, and build your first complete agent. A dedicated troubleshooting lecture covers every common error you might hit.
Section 3 — Built-In Tools Deep Dive
A systematic tour of every built-in tool the SDK provides:
File tools — Read, Write, Edit — including the critical Write vs Edit distinction
Shell tools — Bash for terminal commands, Monitor for live process output
Search tools — Glob and Grep with a beginner-friendly regex introduction
Web tools — WebSearch and WebFetch for live internet access
User interaction — AskUserQuestion with the complete human-in-the-loop flow explained clearly — including how the HTTP connection, streaming input, and keep-alive mechanism work together
Section 4 — Permissions & Safety
Control exactly what your agent is allowed to do. The complete 6-gate permission evaluation flowchart. The difference between allowed_tools, disallowed_tools, and the five permission modes. How to use PreToolUse hooks to automatically block dangerous operations. By the end of this section you will know how to build agents that are safe enough for production.
Section 5 — Hooks: Controlling Agent Behavior
Run your own Python code at key moments in the agent loop. Learn which hook events the Python SDK supports, how callbacks and matchers fit together, and how a hook's response can allow, deny or change what the agent does:
PostToolUse — log every tool call to a JSON Lines audit file and pair calls with their results
Changing tool output — replace what a tool returns and add extra context for the agent
UserPromptSubmit — inject context into every prompt without changing what the user typed
Hands-on — build an agent with a file-change audit log and a guard that blocks edits to protected files, verified against the real files on disk
Section 6 — Sessions & Context Management
Give your agents a memory. See where the SDK saves every conversation, then resume past sessions by ID, continue the most recent one, and hold multi-turn conversations with ClaudeSDKClient. Fork a session to try a different approach without losing the original, and use file checkpointing to rewind the files an agent changed. Track context window usage and estimate cost, compact long conversations, and cap runs with turn and budget limits. The hands-on project brings it all together in a multi-turn agent that analyses, fixes, rewinds and re-fixes a real bug.
Section 7 — Subagents: Delegation & Multi-Agent Workflows
Turn one agent into a team of specialists. Understand how delegation works and what a subagent sees and returns, then:
Hand work to the built-in general-purpose subagent
Define your own specialists with AgentDefinition, with their own instructions, tools and model
Track what every subagent did using parent_tool_use_id and task messages
Build parallel, sequential and mixed pipelines, and resume a specialist where it left off
Add guardrails with SubagentStart and SubagentStop hooks, concurrency and depth limits, budget caps and cost tracking
Hands-on — a code-review and test-generation pipeline that finds, proves and fixes a real bug, verified by your own pytest run
Section 8 — MCP: Connecting External Systems
Connect your agents to tools and data beyond the built-ins with the Model Context Protocol. Learn how MCP servers work and the three ways to connect them, then:
Build custom tools in Python with the @tool decorator and an in-process server
Give tools real application data, strict input validation and clear error messages
Connect a local MCP server over stdio, a SQLite bug tracker running as its own process
Connect a remote MCP server over HTTP with just a URL, and combine remote and local tools in one agent
Manage many servers at once: check their status, handle failures, switch servers on and off, and guard risky tools with hooks
(One more lecture is coming: a hands-on capstone.)
How This Course Is Delivered
Every coding lecture runs in Google Colab — click the link in the course resources and you are coding immediately. No local Python setup, no virtual environments, no dependency headaches. Each lecture comes with a solution notebook hosted on GitHub.
The course uses claude-haiku-4-5/claude-haiku-5-5 by default — the fastest and most cost-effective Claude model — keeping your API costs low while you learn. You can switch to any Claude model with a single variable change.
Requirements
Basic Python — functions, loops, variables
A Google account — for Colab
An Anthropic API key — API usage is billed by Anthropic, so you may need to add credit to your Console account. The course uses the lowest-cost Claude model by default.
Why Learn This Now
AI agents are moving from demos to production. Developers who can build, control, and constrain autonomous agents have a genuine skill advantage. The Claude Agent SDK is production-grade, actively maintained by Anthropic, and powers one of the most widely used AI coding tools in the world. This course gives you a solid foundation — built on real code, real agents, and real production-safety patterns.