Cookies

With your permission, we use Google Analytics cookies to measure visits and improve the site. Necessary cookies are always on. You can change your choice or withdraw consent anytime in the footer, under Cookie settings. Cookie Policy

Skip to content

Claude Code · 7 min

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.

Central glass sphere connected by orbits of light to three smaller spheres and small cubes.

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

Ask AI about this guide:

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 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.

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 invoked
plannerCreates detailed implementation plansBefore building a new feature
code-reviewerReviews written code and flags problemsAfter writing or modifying code
tdd-guideGuides test-driven developmentWhen creating new features
security-reviewerAudits security vulnerabilitiesBefore publishing code with authentication
architectMakes system architecture decisionsIn projects with complex technical decisions
refactor-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 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.

Components for this task

We hand-picked the agents, skills and commands that handle this kind of work: Agents and skills for code review · Agents, skills and commands for automated testing · Agents and skills for debugging and error diagnosis.

Frequently asked questions

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.

Want to put this to work in your business?

1,859 ready-to-copy AI prompts, by industry.

Get started - €7.99/month

Keep reading

Save hours every week with AI, no hassle

Doutor AI gives you 1,859 ready-to-copy AI prompts, by industry and in plain English - plus a complete technical library for those who want to go further.

See plans