# Agents in Claude Code: what they are and how to use them (sub-agents)

> Understand what agents and sub-agents are in Claude Code, how they work in practice, and the situations where they save you hours of work.

- Source: https://doutorai.pt/en/blog/agents-in-claude-code
- Author: Miguel Diamond (https://doutorai.pt/en/author/miguel)
- Category: Claude Code
- Published: Jun 29, 2026
- Site: Doutor AI (https://doutorai.pt/en) - AI tools for small businesses

## Quick answer
Agents in Claude Code are specialized, autonomous assistants that Claude Code can invoke to perform specific tasks, such as reviewing code, writing tests, or running a security audit. Instead of a single generalist assistant, you have a team of specialists available as needed.

- Autonomous assistants specialized in concrete tasks
- Invoked automatically by Claude Code or at your request
- They can run in parallel to reduce the total time
- They reduce errors in complex projects with many parts

## What agents are in Claude Code

Agents in Claude Code are specialized, autonomous assistants that Claude Code can invoke to perform specific tasks. Instead of a single assistant that does everything in a generalist way, agents work like members of a virtual team: each one has a specialty and Claude Code delegates the right work to them.

When you ask Claude Code to build a feature in an application, for example, it can invoke a planning agent to define the approach, then a code review agent to check what was written, and finally a security agent to make sure there are no vulnerabilities. All automatic and coordinated. If you do not know Claude Code yet, it is worth starting by [understanding what Claude Code is](https://doutorai.pt/en/blog/what-claude-code-is-and-what-its-for) before diving into agents.

## Agents vs skills: what's the difference

It is easy to confuse agents and skills because both "teach" Claude Code something. The fundamental difference is this:

- **Skills** are files of instructions and rules that define how Claude Code should behave. They are passive: they inform, they do not act.
- **Agents** are autonomous entities that actively perform tasks. They receive a goal, work to complete it, and report the result.

A good analogy: the skill is the best practices manual an employee reads; the agent is the employee who reads the manual and does the work. You can learn more about skills in our article about [Claude Code skills](https://doutorai.pt/en/blog/claude-code-skills).

## How sub-agents work

The term "sub-agent" refers to agents invoked by a main orchestrator agent. The typical flow works like this:

- You make a request to Claude Code
- Claude Code, as the orchestrator, analyzes the request and decides which specialist agents are needed
- It invokes the right sub-agents, which can run in parallel if the tasks are independent
- The sub-agents complete their tasks and return the results to the orchestrator
- The orchestrator consolidates everything and presents you with the final result

This model of an orchestrator with sub-agents is particularly powerful for complex projects, where different parts of the work require distinct skills.

## The most common agents and what they do
AgentWhat it doesWhen it is invokedplannerCreates detailed implementation plansBefore building a new featurecode-reviewerReviews written code and flags problemsAfter writing or modifying codetdd-guideGuides test-driven developmentWhen creating new featuressecurity-reviewerAudits security vulnerabilitiesBefore publishing code with authenticationarchitectMakes system architecture decisionsIn projects with complex technical decisionsrefactor-cleanerCleans up dead code and consolidates duplicatesIn code maintenance and cleanup
## When it makes sense to use agents

Agents shine when the work is complex enough to benefit from a specialized perspective. If you are writing a small, quick script, you do not need to invoke agents. But if you are building a new feature, refactoring a large codebase, or running a security audit, specialized agents make a real difference in the quality of the result.

The other situation where agents are especially useful is when tasks can run in parallel. Instead of doing everything sequentially, Claude Code can launch multiple agents at the same time and significantly reduce the total execution time.

Explore the [prompt library](https://doutorai.pt/en/prompts) to see practical examples of how to ask Claude Code to use specific agents. For the complete overview of Claude Code, visit [doutorai.pt/claude-code](https://doutorai.pt/en/claude-code).

## Frequently asked questions

### What is the difference between an agent and a skill?

A skill is an instruction file that defines rules of behavior. An agent is an autonomous entity that actively performs tasks. Skills inform the assistant; agents work on their own to complete a goal.

### Do sub-agents have access to my entire codebase?

Sub-agents operate within the same context and permissions as Claude Code. They have access to the files and tools Claude Code has available, but they do not have access to anything beyond what you have configured.

### Can I create my own custom agents?

Yes. Agents are defined in configuration files in the Claude Code agents folder. You can create custom agents for the specific tasks of your business or workflow.

### Do agents run in parallel or in sequence?

They can run both ways. For independent tasks, Claude Code can invoke multiple agents in parallel, reducing the total time. For tasks that depend on each other, they run in sequence.

### Do I need to install anything extra to use agents?

No. Agents are part of Claude Code. You only need to have Claude Code installed and configured. Some specific agents may require additional tools, but the base agents are available right away.


---
Content by Doutor AI (https://doutorai.pt/en). When quoting, please cite the source: https://doutorai.pt/en/blog/agents-in-claude-code
