Complete Guide to Building Agents with the Claude Agent SDK
Summary
Nader Dabit walks through building a code review agent from scratch using the Claude Agent SDK (@anthropic-ai/claude-agent-sdk). The SDK exposes the same engine that powers Claude Code as a library — the agent loop, built-in tools (Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch), and context management. The tutorial covers setup in TypeScript, configuring the agent loop, wiring tools, and managing context windows. Stack: Claude Code CLI, @anthropic-ai/claude-agent-sdk, TypeScript, Claude Opus 4.5.
Why This Was Bookmarked
“complete guide to building agents with the Claude Agent SDK”
The SDK is the next evolution of how we run agents. Our current architecture in SOUL.md runs everything through Claude Code sessions — the SDK lets us build standalone, specialized agents that use the same engine without the CLI wrapper. This is the path from “one COO agent doing everything” to “a team of purpose-built agents.”
Key Ideas
- Same engine, library form — the SDK is not a wrapper or abstraction layer; it’s the actual Claude Code agent loop extracted as a package
- Built-in tools come free — Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch are all available out of the box, same as Claude Code
- Agent loop handles orchestration — tool calls, retries, context management, and multi-turn reasoning are managed by the loop, not by the developer
- TypeScript-first — the SDK is designed for TypeScript, making it natural to compose with existing Node tooling
- Context management is explicit — the SDK gives you control over how context windows are managed, which matters for long-running agents
- Code review agent as tutorial — the walkthrough builds a practical agent that reads a codebase, identifies issues, and produces structured feedback
Connections
This is the bridge between our current setup and a multi-agent architecture. Right now we run everything through Claude Code channels (see 04-tooling/2026-03-29-infrastructure-decisions). The SDK would let us spin up dedicated agents for specific functions — each one a standalone skill in the 06-reference/concepts/skills-as-building-blocks sense.
The built-in tool set maps directly to the nine skill categories from 06-reference/2026-04-04-anthropic-skills-internally — the SDK agents would use the same primitives our skills already use.
Compared to 06-reference/2026-04-04-snap-agent-format, the SDK takes an imperative approach (build the agent in code) rather than a declarative one (define it in YAML). Both are valid; the SDK is closer to how we already work.
The production agent patterns in 06-reference/2026-04-04-100x-business-with-ai would be implemented using this SDK once we need agents that run independently of Claude Code sessions.
Open Questions
- At what scale does our current “everything through Claude Code” model break, and does the SDK become necessary?
- Could we build a vault compilation agent or inbox processor as a standalone SDK agent?
- How does the SDK handle long-running agents — does it manage its own context window rotation, or do we need to build that?
- What’s the deployment story — do SDK agents run as Node processes on the Mac Mini alongside Claude Code, or do they need separate infrastructure?