Lead Gen Jay
SubagentsLesson 1 of 27

Introduction

2 min readLesson 1

Subagents are specialized AI assistants that Claude Code can delegate tasks to. Each subagent has a specific purpose, uses its own context window separate from the main conversation, and can be configured with specific tools and a custom system prompt.

Think of subagents like coworkers on a team. Instead of doing everything yourself, you hand off specific jobs — researching a codebase, reviewing code, running tests — to the right specialist. Claude Code stays focused on your main task while subagents work independently, then report back with results.

Subagents matter because complex projects often involve multiple concerns at once. You might need to explore how authentication works in your app and check what test patterns exist and plan an implementation — all before writing a single line of code. Without subagents, Claude Code would handle each step sequentially in one long conversation, eating up context window space. Subagents keep the main conversation clean and let work happen in parallel.

Claude Code includes several built-in subagent types. Here are the most common ones:

  • Explore — searches codebases quickly by finding files, scanning for keywords, and answering structural questions
  • Plan — designs implementation strategies, identifies critical files, and considers trade-offs
  • general-purpose — handles broad, multi-step tasks with full tool access

You can launch a subagent using the Agent tool. For example, to search your codebase for all API endpoints:

Agent(subagent_type="Explore", prompt="Find all API route handlers and list their HTTP methods and paths")

You can also launch multiple subagents at the same time. If you need to understand both the database schema and the frontend components, Claude Code can spin up two Explore agents in parallel — one for each concern — and get answers faster than working through them one at a time.

Key takeaway: subagents protect your main conversation's context window while enabling parallel, specialized work. When you see Claude Code delegate to a subagent, it is keeping your session efficient by offloading focused tasks to purpose-built assistants that report back only what you need.