This is the practical guide to building and running agents on Claude. Read the overview first if you haven't — it covers what agents are conceptually. This post covers the specific paths, primitives, and patterns on Anthropic's platform.
Why Claude leads on agents in 2026
- Claude Code is the most mature developer-facing agent product in the market. Subagents, skills, hooks, MCP, CLAUDE.md, slash commands — all designed for sustained agentic work.
- MCP (Model Context Protocol) is Anthropic's open standard that's been adopted by every major AI vendor. The MCP server ecosystem is the broadest of any AI platform.
- Constitutional AI training makes Claude particularly cautious about destructive actions — useful when the agent is doing real work.
- Opus 4.7 (and 1M context) is reasoning-capable enough for sustained multi-step plans.
- Tool-use API design has been refined over many iterations — the JSON schemas and parallel tool calls are clean.
Three paths to running Claude agents
- Claude Code (CLI) — the agent runtime on your machine. Best for development work.
- Anthropic API + Agent SDK — build custom agents in code. Best when agents are part of your product (your iOS app's backend, say).
- Claude.ai with connectors — agentic features inside the consumer chat product. Best for non-developer users.
Path 1: Claude Code (recommended starting point)
For most readers, the right way to use Claude agents is Claude Code. Install once, run in any project directory, agentic by default.
What Claude Code gives you out of the box:
- Filesystem read/write tools.
- Bash command execution (sandboxed).
- Web fetch.
- Subagent spawning.
- MCP server support.
- Slash commands for control (
/agents,/skills,/mcp,/usage,/compact). - CLAUDE.md project-context support.
- Hook system for lifecycle events.
For a deep guide on Claude Code workflow, see Claude at Maximum Efficiency.
Path 2: Anthropic API + Agent SDK
For programmatic agents inside your own software (e.g., your iOS app's backend agent that handles user requests), the API approach is right.
The minimum viable Claude agent in Node:
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic();
const tools = [
{
name: 'read_file',
description: 'Read a file from disk',
input_schema: { type: 'object', properties: { path: { type: 'string' } }, required: ['path'] }
},
{
name: 'write_file',
description: 'Write a file to disk',
input_schema: { type: 'object', properties: { path: { type: 'string' }, content: { type: 'string' } }, required: ['path','content'] }
}
];
async function runAgent(goal) {
let messages = [{ role: 'user', content: goal }];
while (true) {
const r = await anthropic.messages.create({
model: 'claude-sonnet-4-6',
max_tokens: 4096,
tools,
messages
});
messages.push({ role: 'assistant', content: r.content });
if (r.stop_reason === 'end_turn') return r.content;
const toolUses = r.content.filter(b => b.type === 'tool_use');
const toolResults = [];
for (const t of toolUses) {
const result = await executeTool(t.name, t.input);
toolResults.push({ type: 'tool_result', tool_use_id: t.id, content: JSON.stringify(result) });
}
messages.push({ role: 'user', content: toolResults });
}
}
That's the loop. Real agents wrap this with: step limits, error handling, human-in-the-loop checkpoints, budget tracking, observability.
Anthropic also publishes a higher-level Agent SDK that handles the loop, conversation state, and common tool patterns. For sustained agent work in your own code, start there.
Path 3: Claude.ai with connectors
For non-developer users, agentic Claude lives in claude.ai with connectors enabled. Set up the Google Drive / Notion / Slack / GitHub connectors in Settings and you can ask Claude to read, search, and act across those tools conversationally.
Limitations vs Claude Code: no filesystem write on your local machine (cloud-only), no bash execution, no subagent spawning. Best for chat-style agentic tasks ("search my Notion for X and summarize") rather than sustained development.
MCP — the agent capability layer
MCP (Model Context Protocol) is the standard for adding tools to a Claude agent. Each MCP server exposes a set of tools that the agent can call. The MCP ecosystem in 2026 includes hundreds of servers covering: filesystems, GitHub, Slack, Linear, Notion, Google Drive, Apple Notes, Figma, Stripe, App Store Connect, AWS, Railway, Vercel, browsers (Claude in Chrome, Playwright), databases, custom APIs, and much more.
To use an MCP server in Claude Code: add it to your settings file or run /mcp. Once installed, its tools appear automatically in the agent's tool list. Claude picks the right tool based on the task.
For custom MCP servers, write one in TypeScript / Python following the spec. ~50 lines of code for a basic server with 1-3 tools.
Subagents and parallel work
A subagent is a fresh Claude instance spawned by the main agent for a sub-task. The main agent passes a goal, the subagent runs its own loop, returns a summary.
Why use subagents:
- Parallel work (research + implementation in parallel).
- Context isolation (the subagent's context doesn't pollute the main).
- Specialization (one subagent role-played as a code reviewer, another as a test writer).
- Cost (a focused subagent in a fresh small context is cheaper than the main agent continuing a long thread).
Define subagents in your project's .claude/agents/ folder or globally in ~/.claude/agents/. Each subagent has a name, model preference, allowed tools, and a system prompt.
Computer Use
Anthropic's Computer Use API gives Claude a virtual mouse and keyboard. Claude can take a screenshot, decide where to click, type, scroll — effectively driving a computer the way a human does.
Computer Use is still maturing — latency is high (seconds per action), accuracy varies, costs are real. Best for tasks no MCP server exists for. For most workflows in 2026, MCP servers + Claude Code beat Computer Use; reserve Computer Use for the gap cases.
Patterns that work in production
- Plan → Implement → Verify. Have the agent write a plan first (markdown checklist), then execute step by step, then verify.
- Spec-first. Write a clear input/output spec as the first turn. The agent's planning quality improves dramatically.
- Confirmation gates. Before destructive ops (delete, deploy, send), require explicit user confirmation.
- Step budgets. Cap any agent run at N steps. Force a summary at the budget.
- CLAUDE.md discipline. Your project's CLAUDE.md is the agent's persistent system prompt. Invest in it.
- Observability. Log every tool call and outcome. Replay-from-log is invaluable when debugging an agent that went wrong.
- Test-driven agents. Have the agent write its own tests, then implement to pass them. Reduces hallucination.
First Claude agent in 30 minutes
- Install Claude Code:
curl -fsSL https://claude.ai/cli/install | sh - Run
claudein a project directory. - Ask it to do something with a clear scope: "Read the README and write a new test file that covers the function described in section 3."
- Watch the agent loop — it reads files, writes the test, runs it, fixes any issues.
- Try installing an MCP server:
/mcp install— pick something like the GitHub MCP. Notice the tool list grow. - Define your first subagent in
.claude/agents/reviewer.md— system prompt that role-plays as a critical code reviewer. Invoke with the agent tool. - Add a
CLAUDE.mdwith your project's conventions. Notice how the agent's behavior aligns. - Try a harder task — multi-file refactor, full feature implementation, complex debug. See what works and what doesn't.
The Claude agent path has the steepest improvement curve in the industry today. A week of focused practice on Claude Code with MCP and subagents will change how you work.
See also: Agentic AI Overview, Agentic AI in ChatGPT, Agentic AI in Gemini, Agentic AI in Grok, Claude at Maximum Efficiency.
- Anthropic — Agents and Tools documentation
- Anthropic — Claude Code
- Model Context Protocol — Specification & servers