Claude Agent SDK
The Claude Agent SDK is the production harness behind Claude Code, available standalone. It ships the loop that already works — gather context, take action, verify — plus a real filesystem, a shell, subagents, and a permission system. Here's the shape.
What you'll learn
- What the Claude Agent SDK is — Claude Code's engine, standalone
- The loop it's built around — gather context, take action, verify work
- Built-in powers — filesystem, shell, subagents, MCP, skills, permissions
- When to reach for it versus LangGraph or a crew
Before you start
The most capable agent most people have actually used is a coding agent — Claude Code, fixing bugs across a real repository. Here is the interesting part: the engine underneath it is available on its own. The Claude Agent SDK is that harness, extracted from Claude Code so you can build your agent on the same machinery. You don’t reassemble the agent loop from parts; you inherit the one that already runs in production.
What you’re actually getting
Most frameworks hand you a toolbox and some lumber and say “build the workshop.” The Agent SDK hands you the workshop Claude Code already works in — wired for power, with the safety guards installed — and asks you to describe the job. Concretely, it ships:
- A real filesystem and shell: the agent can read and write files and run commands, not just call functions you pre-wrote.
- Built-in tools: file read/write/edit,
Bash, web search and fetch, and the ability to spawn subagents for parallel sub-tasks. - MCP support, so any MCP server becomes available, and Skills (AGENTS.md and reusable instructions).
- A permission system with modes, so the agent asks before dangerous actions instead of acting unsupervised.
- Automatic context management — it compacts long histories so the agent doesn’t fall off the end of its context window mid-task.
It comes in Python and TypeScript.
The loop it’s built around
The SDK encodes a specific, opinionated loop that Anthropic found makes agents reliable. It is three steps, repeated:
- Gather context. Don’t stuff everything into the prompt up front. Let the agent pull what it needs — read the relevant files, search, recall prior state.
- Take action. Edit a file, run a command, call a tool — real effects on a real environment.
- Verify work. Run the tests, read the command’s output, check the result against the goal. If it’s wrong, loop back with that feedback.
The shape of an agent
# requires: pip install claude-agent-sdk
import anyio
from claude_agent_sdk import query, ClaudeAgentOptions
async def main():
options = ClaudeAgentOptions(
system_prompt="You are a careful data-engineering assistant.",
allowed_tools=["Read", "Bash", "WebSearch"], # least privilege
permission_mode="default", # confirm risky actions
)
# query() streams the agent's messages as it gathers, acts, and verifies.
async for message in query(
prompt="Summarize the CSVs in ./data and write report.md",
options=options,
):
print(message)
# For multi-turn, interactive sessions, use ClaudeSDKClient instead of query().
anyio.run(main)
Notice allowed_tools and permission_mode: you grant the agent exactly the
capabilities the task needs (least privilege) and decide whether it acts freely or
pauses for confirmation on risky steps. That permission layer is the difference
between a demo and something you’d point at a real repo.
Why verify is the load-bearing step
Because an agent that acts without checking compounds its mistakes: a wrong edit becomes the foundation for the next wrong edit, and the errors cascade silently. An agent that verifies — runs the test, reads the traceback, diffs the output against the goal — catches the mistake while it’s still one step deep, then fixes it. The model’s raw intelligence sets the ceiling; the feedback loop is what reaches it. This is the same reason a real filesystem and shell matter so much: they make verification cheap and concrete (run the tests) instead of the agent merely asserting it’s done.
Where it fits
In one breath
- The Claude Agent SDK is Claude Code’s production harness, standalone — you inherit a working agent loop instead of assembling one. Python and TypeScript.
- It’s built around a three-step loop: gather context → take action → verify work, repeated until the result checks out.
- You get a real filesystem and shell, built-in tools (
Read,Bash, web search), subagents, MCP, Skills, automatic context management, and a permission system. - Grant capability with
allowed_tools(least privilege) and control autonomy withpermission_mode— the line between a demo and a production agent. - Verify is the load-bearing step: it catches mistakes one step deep instead of letting them cascade. Reach for the SDK for computer-using tasks; pick LangGraph for deterministic graphs and a crew for role-based collaboration.
Quick check
Quick check
Next
You’ve now seen the major agent frameworks — LangChain, LangGraph, LlamaIndex, MAF, ADK, the OpenAI Agents SDK, CrewAI, and this one. Next, the production concerns that apply across all of them: agent memory.