One-Line Summary: The Claude Agent SDK is Anthropic's official toolkit for building harnesses (or harness-shaped applications) on top of Claude — it is the SDK that Claude Code itself is built on, exposing primitives for agent loops, tools, hooks, sub-agents, and MCP.
Prerequisites: Harness vs. framework vs. SDK, claude-code-as-harness, what is an AI harness
What Is the Claude Agent SDK?
If Claude Code is the harness, the Claude Agent SDK is the toolkit you would use to build another one — or any application with comparable agentic structure. It exposes opinionated primitives: Agent (the loop), Tool (a callable), Hook (a lifecycle event handler), SubAgent (a scoped child), MCPServer (a remote tool source), Memory (a pluggable store). The SDK is available in TypeScript and Python; both surfaces are kept deliberately close to each other.
The SDK is best thought of as Anthropic's answer to two questions developers kept asking: how do we build something that feels like Claude Code but for our domain, and how do we add agentic capabilities to an existing application without adopting a third-party framework with its own opinions.
How It Works
A minimal SDK program defines tools, instantiates an agent, and runs it:
import { Agent, Tool } from '@anthropic-ai/claude-agent-sdk';
const search = new Tool({
name: 'search',
description: 'Search the company wiki',
schema: { query: 'string' },
execute: async ({ query }) => await wiki.search(query),
});
const agent = new Agent({
model: 'claude-opus-4-7',
system: 'You are a helpful research assistant.',
tools: [search],
hooks: {
preToolUse: async (call) => /* validate, log, or block */,
},
});
const result = await agent.run('What is our deployment policy?');The loop, retry behavior, tool dispatch, and conversation management are all the SDK's responsibility. You can extend any of them via hooks or by subclassing. Sub-agents are first-class — agent.spawn(...) returns a child with its own scoped tools and termination condition.
Why It Matters
Three reasons this SDK matters for the course. First, every concept the course teaches has a direct API in the SDK; if you want to move from understanding to running code, the SDK is the shortest path. Second, the SDK is what you would use to build a custom harness — the topic of the course's companion blueprint. Third, the SDK is the cleanest answer to "how do I add agent capabilities to my existing app without adopting a framework's opinions."
Key Technical Details
- Model-agnostic enough to be useful: Although optimized for Claude, the SDK supports drop-in providers via the same interface as the Claude API.
- Streaming-first: All loops yield events (token deltas, tool calls, tool results) so you can stream to a UI without buffering.
- Hooks parity with Claude Code: The hook events (
preToolUse,postToolUse,onStart,onStop, etc.) match what Claude Code exposes — so a hook authored for the SDK can run inside Claude Code (and vice versa for many cases). - MCP client built in:
agent.useMCP(server)connects and registers tools. - Memory adapters: In-memory, file-based, and BYO. Vector-DB integrations live in the ecosystem.
- Sub-agents are isolated: A spawned sub-agent has its own context, history, tool registry, and budget — not just a different system prompt.
How Harnesses & Frameworks Implement This
| Use case | Use the Claude Agent SDK | Use a framework | Use a harness |
|---|---|---|---|
| Build a coding harness | ✅ | ⚠ heavy | ✗ |
| Add agent to existing app | ✅ | ✅ | ✗ |
| Multi-vendor abstraction | ⚠ Claude-tilted | ✅ (LangGraph) | ✗ |
| End-user product | needs UI work | needs UI work | ✅ |
| Run as a binary | needs packaging | needs packaging | ✅ |
Connections to Other Concepts
harness-vs-framework-vs-sdk.md— The category the SDK occupies.claude-code-as-harness.md— A reference application of the SDK.hooks-and-lifecycle-events.md— The SDK's lifecycle surface.sub-agents-as-primitives.md— How the SDK exposes sub-agents.mcp-as-the-universal-tool-bus.md— How MCP integrates.
Further Reading
- Anthropic, Claude Agent SDK documentation — Current reference.