TL;DR
Claude Agent SDK vs Claude Code explained: same engine, two surfaces. Here is the concrete decision line, plus where Managed Agents fits as the hosted third option.
Direct answer
Claude Agent SDK vs Claude Code explained: same engine, two surfaces. Here is the concrete decision line, plus where Managed Agents fits as the hosted third option.
Best for
Developers comparing real tool tradeoffs before choosing a stack.
Covers
Verdict, tradeoffs, pricing signals, workflow fit, and related alternatives.
Read next
Claude Code Routines and Managed Agents scheduled deployments both run Claude on a schedule - here is how the triggers, pricing, and limits differ, and which one fits your recurring agent work.
9 min readThe 2026 agent decision is not CrewAI vs LangGraph. It is whether your loop lives in vendor infrastructure, a self-hosted graph runtime, or a plain while-loop you wrote yourself. Here is how to choose.
9 min readClaude Code subagents vs agent teams vs workflows: who holds the plan, the hard limits (16 concurrent, 1,000 agents per run), and which primitive fits your task.
9 min readLast updated: June 11, 2026
Type "claude agent sdk vs" into a search bar and the autocomplete finishes the sentence for you. The confusion is understandable: both products run the same agent loop, share the same tools, and even share a binary. But they answer different questions, and in June 2026 the line got sharper.
The short version: Claude Code is the interactive product you drive from a terminal. The Claude Agent SDK is that same harness packaged as a Python and TypeScript library you embed in your own software. And Claude Managed Agents is the third option, where Anthropic hosts the agent loop and the sandbox so you operate neither. This post draws the decision line between all three, using only what is in the official docs as of June 2026.
query() and processes the message stream.Anthropic's own SDK docs draw the same line: interactive development and one-off tasks go to the CLI; CI/CD pipelines, custom applications, and production automation go to the SDK. Their words: "Many teams use both: CLI for daily development, SDK for production."
For the full background on the CLI side, see our complete guide to Claude Code. If you are comparing across vendors rather than within Anthropic's stack, that is a different question - see OpenAI Agents SDK vs Claude Agent SDK.
| Dimension | Claude Code (CLI) | Claude Agent SDK |
|---|---|---|
| What it is | Interactive terminal product | Library: @anthropic-ai/claude-agent-sdk (npm) or claude-agent-sdk (pip, Python 3.10+) |
| Who orchestrates | You, conversationally, turn by turn | Your code, via query() options |
| Subagents | Markdown files in .claude/agents/ | Programmatic AgentDefinition objects (filesystem agents also load) |
| Fleet management | Agent view dashboard, background sessions under a supervisor process | Workflow tool (TypeScript SDK v0.3.149+), resumable subagents |
| Scheduling | Routines: schedule, API, and GitHub triggers on Anthropic-managed cloud | Your own cron, queue, or webhook calling the SDK or claude -p |
| Permissions | Interactive prompts, plan approval, permission modes | allowedTools, permissionMode, hooks as in-process callbacks |
| Subscription billing | Interactive plan limits | Separate monthly Agent SDK credit starting June 15, 2026 |
| Auth for shipped products | Not applicable | API key required; claude.ai login may not be offered to your end users |
That last row matters if you are building a product: the SDK overview states that Anthropic does not allow third-party developers to offer claude.ai login or rate limits in their products unless previously approved.
In the CLI, subagents are markdown files. In the SDK, the recommended path is the agents parameter on query(): a dictionary of AgentDefinition objects, each with a required description and prompt, plus optional tools, disallowedTools, model (aliases include fable, opus, sonnet, haiku, inherit), skills, memory, mcpServers, maxTurns, background, effort, and permissionMode.
Because definitions are plain objects, you can build them with factory functions at request time - a stricter security reviewer on a bigger model for high-stakes runs, a cheaper one otherwise. Programmatic definitions take precedence over same-named filesystem agents. Two sharp edges from the docs: include Agent in allowedTools to auto-approve subagent invocations, and never give a subagent the Agent tool, because subagents cannot spawn their own subagents. The tool was also renamed from Task to Agent in Claude Code v2.1.63, and current SDK releases still emit Task in a few fields, so robust code checks both names.
When an SDK subagent completes, the Agent tool result includes an agentId. Capture it alongside the session_id, pass resume: sessionId on a later query() call, and reference the agent ID in your prompt: the subagent continues with its full prior history, including tool calls and reasoning. Transcripts persist separately from the main conversation, survive compaction, and are cleaned up after 30 days by default. The built-in Explore and Plan agents are one-shot and return no agentId. This is the building block for multi-step product flows where an analysis from request one informs a follow-up in request two.
Subagents handle a few delegated tasks per turn. For runs that coordinate dozens to hundreds of agents, the TypeScript SDK (v0.3.149 and later) exposes the Workflow tool: orchestration moves into a JavaScript script the runtime executes outside the conversation, with intermediate results held in script variables instead of Claude's context. The runtime caps runs at 16 concurrent agents and 1,000 agents total, which bounds the cost of a runaway script. Include Workflow in allowedTools to auto-approve runs.
One more SDK-side fact worth planning around: starting June 15, 2026, Agent SDK and claude -p usage on subscription plans draws from a new monthly Agent SDK credit, separate from interactive limits (verified June 10, 2026 on the SDK overview page). We broke down the budgeting implications in our Agent SDK credit meter analysis.
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
From the archive
Jun 11, 2026 • 10 min read
Jun 11, 2026 • 8 min read
Jun 11, 2026 • 8 min read
Jun 11, 2026 • 9 min read
Permission prompts, plan approval, the /workflows progress view with per-agent token counts and pause/stop/restart keys, effort controls, and rewind. None of this exists when your code is the operator; in claude -p and the SDK there is nobody to prompt, so tool calls follow configured rules without interactive confirmation.
claude agents opens one dashboard for every background session across all your projects, grouped by needs-input, working, and completed. It is a research preview requiring v2.1.139 or later. Sessions run under a separate supervisor process, so they survive closing the terminal, machine sleep, and auto-updates. Dispatch from the view, from inside a session with /bg, or from the shell with claude --bg "prompt". One honest caveat from the docs: each background session uses your subscription quota independently, so check your limits before dispatching many at once.
Routines are the CLI ecosystem's answer to scheduled automation: a saved configuration of prompt, repositories, and connectors that runs on Anthropic-managed cloud infrastructure, so it keeps working when your laptop is closed. Triggers come in three flavors - a schedule, an authenticated HTTP endpoint, or GitHub events like pull_request.opened - and one routine can combine all three. Create them at claude.ai/code/routines or with /schedule in the CLI. Routines are a research preview on Pro, Max, Team, and Enterprise plans with Claude Code on the web enabled, with a daily per-account run cap.
If your "I need the SDK" itch is really "I need this to run nightly without me," a routine may cover it with zero infrastructure.
Claude Managed Agents is a pre-built agent harness running on Anthropic's infrastructure, in beta behind the managed-agents-2026-04-01 header (set automatically by the SDKs, enabled by default for API accounts). You define an Agent (model, system prompt, tools, MCP servers, skills) once, pick an Environment (Anthropic cloud sandbox or a self-hosted sandbox on your own infrastructure), then start Sessions that stream events over SSE.
The official comparison against the Agent SDK is crisp: the SDK runs in your process on your infrastructure with session state as JSONL on your filesystem; Managed Agents runs on Anthropic's side with a managed sandbox per session and a hosted event log. Custom tools flip too - in-process functions with the SDK, an event round-trip with Managed Agents. The docs suggest the path many teams will follow: prototype locally with the SDK, move to Managed Agents for production when you do not want to operate sandboxes and session storage. One compliance note from the overview: because sessions are stateful by design, the beta is not currently eligible for Zero Data Retention or HIPAA BAA coverage.
For how the hosted option stacks up against orchestration frameworks, see Managed Agents vs LangGraph vs DIY.
query() with allowedTools, hooks for audit logging, and headless permission rules are built for pipelines. Budget against the new SDK credit on subscription plans.Skip the SDK if your real need is a recurring job (routines), a one-off batch (claude -p in a script), or parallel work on your own machine (agent view). Reaching for a library when a built-in surface already does the job is how you end up maintaining orchestration code nobody asked for.
Stay with the CLI even for automation-adjacent work when a human reviews every result anyway - dispatching ten background sessions through agent view is often faster than writing the harness to do the same.
Go to the SDK without hesitation when there is no human at the keyboard: webhooks, CI gates, product features, anything needing programmatic AgentDefinitions, resumable subagents, or the Workflow tool at scale.
And go in clear-eyed about maturity labels: agent view and routines are research previews; dynamic workflows are available on all paid plans but require Claude Code v2.1.154 or later, with a /config toggle on Pro; Managed Agents is a beta with the ZDR and HIPAA caveats above. The core CLI and the SDK query() surface are the stable ground.
They share the same engine - the SDK was formerly called the Claude Code SDK, and the TypeScript package bundles a native Claude Code binary - but they are different surfaces. Claude Code is the interactive terminal product; the Agent SDK exposes the same tools, agent loop, and context management as a Python and TypeScript library for your own applications.
Starting June 15, 2026, Agent SDK and claude -p usage on subscription plans draws from a separate monthly Agent SDK credit rather than your interactive usage limits, per the official SDK overview. API-key usage bills through the API as usual. Shipped products must use API key authentication; offering claude.ai login to your users is not permitted without prior approval.
Yes, and more flexibly: define them programmatically with AgentDefinition objects, load the same .claude/agents/ markdown files Claude Code uses, or rely on the built-in general-purpose agent. SDK subagents are also resumable across queries via the returned agentId plus session resume. The one hard limit: subagents cannot spawn their own subagents.
The Agent SDK is a library that runs the agent loop inside your process, on your infrastructure, with state on your filesystem. Managed Agents is a hosted REST API where Anthropic runs the loop and a sandbox per session and persists the event log server-side. Anthropic recommends prototyping with the SDK and considering Managed Agents for production.
Routines, if the job fits their trigger model: cron schedules, an authenticated HTTP endpoint, or GitHub events, all running on Anthropic-managed cloud with no servers to maintain. Choose the SDK when you need custom orchestration, in-process tools, your own infrastructure, or volumes beyond the routine daily run cap.
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Anthropic's Python SDK for building production agent systems. Tool use, guardrails, agent handoffs, and orchestration. R...
View ToolAnthropic's agentic coding CLI. Runs in your terminal, edits files autonomously, spawns sub-agents, and maintains memory...
View ToolAnthropic's flagship reasoning model. Best-in-class for coding, long-context analysis, and agentic workflows. 1M token c...
View ToolOpen-source AI pair programming in your terminal. Works with any LLM - Claude, GPT, Gemini, local models. Git-aware ed...
View ToolTurn a one-liner into a working Claude Code skill. From idea to installed in a minute.
View AppEvery coding agent in one window. Stop alt-tabbing between Claude, Codex, and Cursor.
View AppDesign subagents visually instead of editing YAML by hand.
View AppDeep comparison of the top AI agent frameworks - LangGraph, CrewAI, Mastra, CopilotKit, AutoGen, and Claude Code.
AI AgentsA practical walk-through of how to design, write, and ship a Claude Code skill - from choosing when to trigger, through allowed-tools, to the steps the agent will actually follow.
Getting StartedFire when subagents spawn and finish.
Claude Code
Nimbalyst Demo: A Visual Workspace for Codex + Claude Code with Kanban, Plans, and AI Commits Try it: https://nimbalyst.com/ Star Repo Here: https://github.com/Nimbalyst/nimbalyst This video demos N...

Claude Fable 5 Released: Benchmarks, Pricing, Availability, and Real-World Examples Anthropic has released Claude Fable 5, the first general-use “Mythos class” model, and the video reviews the announ...

Claude Design by Anthropic: Generate a Design System From Your Repo + Build High-Fidelity UI Fast The video reviews Claude Design by Anthropic, calling it a highly differentiated product, and demonst...
Claude Code Routines and Managed Agents scheduled deployments both run Claude on a schedule - here is how the triggers,...
Claude Code subagents vs agent teams vs workflows: who holds the plan, the hard limits (16 concurrent, 1,000 agents per...
Claude Fable 5 vs Gemini: how Anthropic's $10/$50 Mythos-class model compares to Gemini 3.1 Pro's $2/$12 preview on pric...
GPT-5.5 vs Claude Opus 4.8: both cost $5 per million input tokens, so the workhorse-tier decision comes down to output p...
Claude Managed Agents is in public beta with solid sandboxing and session persistence - but the headline orchestration f...
Fable 5 launched June 9 at 2x GPT-5.5's price with a 22-point SWE-Bench Pro gap. Here is the decision framework for choo...

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.