Claude Academy
Sign in

Agent Skills & Subagents · lesson 3 of 4

Claude Agent SDK

The library Anthropic provides for building custom agents that share Claude Code's primitives — tool loop, permission system, hooks, subagents, skills — without writing them from scratch.

What you get for free

  • Multi-turn agent loop with tool use.
  • Permission middleware (allow/deny + user confirmation).
  • Hook system for lifecycle events.
  • Subagent delegation.
  • Skill loading.
  • Session management.
  • Streaming + output formats.

Languages

  • TypeScript / JavaScript (@anthropic-ai/agent-sdk).
  • Python (anthropic-agent-sdk).

Sketch (TypeScript)

import { Agent } from "@anthropic-ai/agent-sdk";

const agent = new Agent({
  model: "claude-sonnet-4-6",
  systemPrompt: "You are a build engineer for our monorepo...",
  tools: [readFileTool, runShellTool, githubMCP],
  permissions: {
    allow: ["Read(./**)", "Bash(pnpm:*)"],
    deny: ["Bash(rm:*)"],
  },
  hooks: {
    PostToolUse: [{ matcher: "Edit", command: "pnpm lint --fix" }],
  },
});

const result = await agent.run({
  prompt: "Bump deps to latest minor and re-run tests.",
});

When to use the Agent SDK vs vanilla API

NeedUse
Quick one-off tool-use scriptVanilla Messages API
Reusable agent with permissions, hooks, subagentsAgent SDK
Coding agent for your repoClaude Code (it IS Agent SDK + ergonomics)
Production multi-tenant agentAgent SDK + your infra

Custom subagents

Define subagent types as you would in Claude Code (.claude/agents/*.md). The SDK loads them automatically.

CCA-F angle

You're unlikely to see Agent SDK syntax on the exam, but you should know it exists and that Claude Code is built on top of it. Architecture questions about "how would you build a custom Claude-powered agent" expect you to recognize the SDK as the answer, not a from-scratch tool loop.

See also