Full-Code · Agent SDKsactive

Claude Agent SDK

also known as Claude Code SDK

Type: full-code  ·  Vendor: Anthropic  ·  Language: Python, TypeScript  ·  License: MIT (Python), proprietary (TypeScript — Anthropic Commercial Terms)  ·  Status: active  ·  Status in practice: emerging  ·  First released: 2025-06-11

Links: homepage docs repo

Embed Claude Code's autonomous agent loop — same tools, same context management — as a programmable library in Python or TypeScript so production agents can read files, run commands, edit code, and execute multi-step workflows.

Description. The Claude Agent SDK is Anthropic's Python and TypeScript library for building agents that run Claude Code's loop inside your own process. It gives you the same tools, agent loop, and context management that power Claude Code, programmable in either language. The SDK exposes built-in tools (Read/Write/Edit/Bash/Glob/Grep/WebSearch/WebFetch/Agent/Skill), MCP servers (in-process and external), filesystem-defined Agents, Skills and Slash Commands under .claude/, hooks, and a canUseTool approval callback. It is the renamed successor of the Claude Code SDK; distinct from the lower-level Anthropic Client SDK (where you implement the tool loop) and from Managed Agents (Anthropic-hosted sandbox).

Agent loop shape. Imperative query() / ClaudeSDKClient loop that wraps the Claude Code harness. Receive prompt → evaluate and respond → execute tools → repeat → return result. Turns continue until Claude produces output with no tool calls. Caller caps the loop with max_turns / maxTurns, max_budget_usd / maxBudgetUsd, effort, and permission_mode. Subagents spawn via the Agent tool, run with their own fresh context, and return a single final message. Sessions persist as JSONL under ~/.claude/projects/ and can be resumed, continued, or forked.

Primary use cases

  • production coding agents that mirror the Claude Code shape
  • agents that need filesystem + bash + browser tools out of the box
  • agents with mid-run approval gates via canUseTool
  • agents using Anthropic skills and MCP servers

Key concepts

  • Agent loop (docs)Same execution loop that powers Claude Code; Receive → Evaluate → Execute tools → Repeat → Return result.
  • Subagents subagent-isolation (docs)Separate agent instances the main agent can spawn for focused subtasks; their context starts fresh and intermediate tool calls stay inside the subagent.
  • Agent Skills agent-skills (docs)Specialized capabilities packaged as SKILL.md files that Claude autonomously invokes when relevant; descriptions load at session start, full content only when used.
  • MCP servers mcp (docs)Three transports — stdio, http/sse, and in-process SDK MCP servers; mcp_servers / mcpServers is a top-level option.
  • Permission modes + canUseTool approval-queue (docs)Permission modes (default / dontAsk / acceptEdits / bypassPermissions / plan / auto-TS-only) layered with canUseTool callback that pauses execution until the host returns a decision.
  • Hooks (docs)Callback functions that run host code in response to agent events (PreToolUse, PostToolUse, PermissionRequest, Stop).

Patterns this full-code implements

Neighbourhood

Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.