what is the claude agent sdk
the claude agent sdk is anthropic's typescript-first library for embedding a claude-driven agent loop in your own program. it ships the parts you'd otherwise rebuild — the tool-use loop, a permission model, lifecycle hooks, a sub-agent primitive, and conventions for skills and system prompts — and leaves the surface (cli, http, ide, ci) to you. the same agentic harness used by claude code, exposed as a library.
who this is for
engineers who already ship typescript and now want an agent that actually does work — edits files, runs commands, opens prs — instead of just chatting. you should be comfortable with async/await and have used the anthropic api at least once. you do not need a production agent codebase to start; every lesson stands alone with small, focused examples.
why this and not just the api
you can build an agent on top of the raw messages api with tool use.
people do. what the sdk gives you is the boring scaffolding around
that loop: a permission system that doesn't rm -rf your
repo on turn three, hook points for telemetry and policy, sub-agent
isolation so a research detour doesn't poison the parent context,
and a skill-loading convention so prompts aren't a tangle of inline
strings. that scaffolding is the difference between a demo and
something you'd run unattended.
how the lessons work
- each lesson is one concept with the smallest possible example — typescript, single file, narrated.
-
we use the real package —
@anthropic-ai/claude-agent-sdk— and call out the spots where you'd otherwise need an api key to follow along. - permissions, hooks, and sub-agents each get their own lesson, because each one is where most "the agent went sideways" stories actually happen.
- lesson eight is the shipping diff — cli vs server vs ide, and what changes for each.
lessons
- 01 what is the claude agent sdk anthropic's typescript-first sdk for building coding agents. the loop, the harness, and the parts the sdk decided to own. 11m
- 02 the query loop — your first agent query() as an async generator. message events, tool-use events, and the shape of one full agent turn. 13m
- 03 tools — file io, bash, and the rest the built-in toolset, defining your own tool, and wiring an mcp server. when to reach for which. 15m
- 04 permissions — the safety model canUseTool, allow / ask / deny, plan mode. the difference between a helpful agent and a destructive one. 12m
- 05 sub-agents — context isolation the Agent tool, when to spawn one, and what survives the handoff back. keeping the parent context clean. 12m
- 06 hooks — pre/post tool, stop, ux lifecycle hooks for lint-on-write, telemetry, custom statuslines. the harness extension points you actually use. 11m
- 07 system prompts and skills tailoring the agent: system prompt overrides, project-level skills, and how the sdk loads context. 12m
- 08 shipping — cli, server, ide packaging an agent as a cli, embedding it in a backend, or driving it from an ide. the diff to production. 14m