Subagents

Specialized AI assistants with independent context for task-specific workflows

What are Subagents?

Subagents are independent Claude instances with their own context windows, tool access, and specialized instructions. They can explore code, execute plans, run in the background, and return summarized results without consuming your main session's context.

Specific Purpose

Each subagent has a defined expertise area

Own Context Window

Separate from main conversation

Configurable Tools

Specific tool access per subagent

Custom System Prompt

Tailored instructions for each agent

NEW in 2.1

New Subagent Features

⚑

Async Subagents

Run subagents asynchronously with Ctrl+B backgrounding

πŸ”€

Context Fork

Use context: fork in skill frontmatter for isolated execution

🎯

Agent Hooks

Define PreToolUse, PostToolUse, and Stop hooks in agent frontmatter

πŸ”„

Disable Agents

Use Task(AgentName) syntax in disallowedTools to disable specific agents

Built-in Subagents

Explore

Fast, read-only agent for searching and analyzing codebases

Model: Haiku (fast)

Tools: Read-only

Plan

Research agent used in plan mode to gather context

Model: Inherits

Tools: Read-only

general-purpose

Capable agent for complex, multi-step tasks

Model: Inherits

Tools: All tools

Agent Frontmatter Fields

FieldDescriptionExample
modelOverride model selectionopus, sonnet, haiku, inherit
skillsEnable specific skills["code-review", "testing"]
hooksDefine agent-specific hooks["pre-review"]
permissionModePermission handling modeinherit, default, bypassPermissions
apiKeyEnvVarCustom API key env variableCUSTOM_API_KEY
enableUndoEnable undo capabilitytrue, false
toolsRestrict available tools["Read", "Edit", "Bash"]
agent.md frontmatter example
---
model: opus
skills:
  - code-review
hooks:
  - security-check
permissionMode: inherit
tools:
  - Read
  - Edit
  - Grep
---

Quick Start

1. Open Subagents Interface

/agents

2. Create New Agent

Choose "Create New Agent" and select project-level or user-level

3. Define the Agent

  • Describe the agent's purpose
  • Select tools to grant access
  • Customize the system prompt

4. Use Your Agent

> Use the code-reviewer subagent to review my changes

Example Subagents

Code Reviewer

Reviews code for quality, security, and best practices

Tools: Read, Grep, Glob, Bash

Debugger

Analyzes errors and implements fixes

Tools: Read, Edit, Bash, Grep

Test Automation

Creates and runs tests automatically

Tools: Read, Write, Bash

Best Practices

1

Design Focused Agents

Create subagents with single, clear responsibilities

2

Write Detailed Prompts

Include specific instructions and examples

3

Limit Tool Access

Only grant necessary tools for better security

4

Version Control

Check project subagents into version control

Ready to Create Your First Subagent?

Start automating specialized tasks with custom AI assistants tailored to your workflow