scalable/ai/claude agent sdk cph / /
8 lessons · ~100 min

claude agent sdk

eight lessons on anthropic's typescript sdk for building coding agents. the same harness shape that drives claude code — tool use, sub-agents, hooks, permissions — exposed as a library you can wrap around your own ui, your own ci, your own runtime.

written for@anthropic-ai/claude-agent-sdk 0.2.119 (typescript)last updatedsdk moves fast — verify against current aws docs before you ship.
query() prompt tool_use result tools results in permissions gate sub-agents spawn hooks wrap skills context in system prompt config in

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

lessons

  1. 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
  2. 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
  3. 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
  4. 04 permissions — the safety model canUseTool, allow / ask / deny, plan mode. the difference between a helpful agent and a destructive one. 12m
  5. 05 sub-agents — context isolation the Agent tool, when to spawn one, and what survives the handoff back. keeping the parent context clean. 12m
  6. 06 hooks — pre/post tool, stop, ux lifecycle hooks for lint-on-write, telemetry, custom statuslines. the harness extension points you actually use. 11m
  7. 07 system prompts and skills tailoring the agent: system prompt overrides, project-level skills, and how the sdk loads context. 12m
  8. 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
scalable labs·cvr 30091604·github·linkedin·hello@scalable.dk