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.

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
| Agent | What it does | When it is invoked |
|---|---|---|
| planner | Creates detailed implementation plans | Before building a new feature |
| code-reviewer | Reviews written code and flags problems | After writing or modifying code |
| tdd-guide | Guides test-driven development | When creating new features |
| security-reviewer | Audits security vulnerabilities | Before publishing code with authentication |
| architect | Makes system architecture decisions | In projects with complex technical decisions |
| refactor-cleaner | Cleans up dead code and consolidates duplicates | In 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.
Keep reading

Claude Code vs Cursor: which is the best AI tool for coding?
We compare Claude Code and Cursor to figure out which is the best AI tool for coding, depending on your profile and how you work.

Claude Code vs GitHub Copilot: a complete comparison
Claude Code and GitHub Copilot are AI tools for developers, but they work very differently. See which one fits your work better.

The best ChatGPT prompts (for your business)
Ready-to-use ChatGPT prompts, organized by business area: customer service, marketing, content, productivity, and more.

Artificial intelligence for businesses: the guide to getting started
A practical guide to artificial intelligence for businesses: where to start, which tools to use, and how to introduce AI to your team without hassle.
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.
