Claude agents

Claude agents, explained

"Agent" is one of the most overloaded words in AI right now. Anthropic ships three different things you might call an agent — and they're not interchangeable. They also overlap with Skills in confusing ways. This page sorts it out.

What's an AI agent (for real)

An AI agent is a program where an LLM decides what actions to take — which tools to call, in what order, and when to stop. The LLM is the brain; the "tools" are functions it can call (read a file, search the web, run a command, query an API).

Strip the hype: an agent is a loop that keeps asking the LLM what to do next, calls the tools the LLM picks, feeds results back in, and repeats until the LLM says "done."

The three Claude agent flavors

Agent SDK

Python / TypeScript library

You write code. Import the library, call query(), and Claude runs the agent loop in your process. Built-in tools (Read, Write, Bash, WebSearch, etc.) work out of the box. Custom tools are plain functions. State lives on your filesystem.

Use it when:you're building a standalone program — CI jobs, internal automation, custom apps — and want full control over the runtime.

Anthropic docs

Managed Agents

Anthropic-hosted REST API

Anthropic runs the agent on their infrastructure. You hit a REST API with prompts and stream back results. Each session gets a managed sandbox; long-running and async sessions work without you operating the box. State lives in Anthropic's event log.

Use it when:you want production agents without hosting them, you have long-running tasks, sandboxing is a hard requirement, or you don't want to think about scaling.

Anthropic docs

Subagents

Markdown files in .claude/agents/

The Claude Code feature that's closest to Skills in spirit. A subagent is a markdown file with YAML frontmatter that defines a specialized assistant: its system prompt, which tools it can use, and (optionally) which model. Your main Claude session spawns it when relevant; it works in its own context window and only the result comes back.

Use it when: you have recurring side-tasks inside a Claude Code session (code review, log analysis, deep research) that would otherwise pollute the main conversation.

Anthropic docs

Skills vs Subagents — same format, different jobs

Both Skills and Subagents are markdown files Claude Code loads from your .claude/ folder. Both define what Claude does using a YAML frontmatter + instructions. The confusion is real — the practical difference is what they're for.

Skill

~/.claude/skills/{name}/SKILL.md

A reusable capabilityClaude follows when the task matches. Same context as your main conversation. "When you write a PR description, do it this way."

  • Recurring workflow with a fixed structure
  • You want the result in your main conversation
  • The work is short and doesn't need its own context

Subagent

~/.claude/agents/{name}.md

A specialized assistant spawned for a side-task. Runs in its own context window with limited tools. Only the summary comes back to your main conversation.

  • Side-task that would flood main context
  • You only need the conclusion, not the work
  • Tool access should be restricted (security/cost)

Concrete example: if you write PR descriptions every day, install the pr-description-writer skill — Claude will use it inline whenever you ask. If you do a giant code review that pulls in 30 files of context, spawn a code-reviewer subagent — it reads everything in a separate window and reports back "5 issues, here they are." Your main session stays clean.

How to actually use them

1. Add a subagent to Claude Code

Create the file ~/.claude/agents/code-reviewer.md with this content:

---
name: code-reviewer
description: Use when reviewing a diff or PR. Spawns a focused reviewer that reads files independently and reports issues.
tools: [Read, Glob, Grep]
---

You are a senior code reviewer. Read the diff carefully and look for:
- Logic bugs
- Edge cases not handled
- Security issues
- Test coverage gaps

Report back with at most 5 most important issues, each with:
- file:line
- the problem
- a suggested fix

Skip nitpicks (formatting, naming preferences). Focus on what actually matters.

Restart your Claude Code session. Now ask: "Use the code-reviewer agent on this PR." Claude spawns the subagent, which reads files in its own context and reports back a clean summary.

2. Build an agent with the Agent SDK

Install:

pip install claude-agent-sdk
# or: npm install @anthropic-ai/claude-agent-sdk

export ANTHROPIC_API_KEY=your-key

Minimum-viable Python agent:

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions

async def main():
    async for message in query(
        prompt="Find and fix the bug in auth.py",
        options=ClaudeAgentOptions(allowed_tools=["Read", "Edit", "Bash"]),
    ):
        print(message)

asyncio.run(main())

Claude reads auth.py, finds the bug, edits it, and runs tests if it can — all autonomously. From here you wire in custom tools, hooks, and your own workflows.

3. Use Managed Agents (REST)

POST to the Managed Agents API. Anthropic runs the loop in their sandbox. You stream back events.

curl https://api.anthropic.com/v1/agents/sessions \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "agent_id": "research-assistant",
    "input": "What changed in the EU AI Act this month?"
  }'

See the Managed Agents docs for the actual schema and SDK clients.

Decision matrix — which one do you actually need?

If you want to…Pick
Standardize a recurring task in Claude CodeSkill
Spawn a specialist for a side-task that would flood contextSubagent
Build an agent that touches my repo / filesAgent SDK
Wire AI into a CI pipelineAgent SDK (headless)
Run agents in production without hostingManaged Agents
Long-running async tasks (hours/days)Managed Agents
Just "ask Claude to do something" one-offPlain prompt — no agent needed

When agents are overkill

  • You can solve the problem with a single LLM call. Don't loop if you don't need to loop.
  • The task has a known, fixed sequence of steps. That's a workflow — write it as code that calls the LLM at specific points.
  • You can't articulate what "done" looks like. Agents need a stop condition. If you can't define one, the agent will spin and burn tokens.
  • Latency matters. Agent loops are slow by definition — multiple LLM calls, often serial. For real-time UX, use a single call.
  • It's a recurring small task in Claude Code. That's a Skill, not an agent.

Where to find ready-made agents

For Subagents (and other Claude Code components), the most comprehensive catalog right now is aitmpl.com/agents. It hosts 600+ agents, plus skills, commands, hooks, and MCP servers, and is supported by Vercel, Neon, and Anthropic open source.

For Agent SDK examples, Anthropic maintains a demos repo: email assistant, research agent, and more.

We don't maintain a competing catalog. What we offer is hand-written Skills (the closely related sibling format) — 128 of them across 12 packs, curated rather than crowdsourced.

Terms worth knowing

The agent space has its own vocabulary. Plain-English definitions for the terms that come up most:

Related comparisons