Modern development moves fast, and maintaining clarity while juggling multiple tasks can be overwhelming. With Claude Code’s sub agents, you get the power of focused AI assistants—each dedicated to a specialized function—working together to optimize your workflow without clutter or confusion.
Understanding Sub Agents
Sub agents are configurable AI personas designed for specific roles like code review, debugging, or data analysis. Each one operates with its own set of instructions and permissions, processing tasks independently and returning targeted results. This structure lets you delegate tasks efficiently without losing the thread of your main project.
Why Use Sub Agents?
- Context Preservation: Separate context windows for each agent keep your main session tidy and focused.
- Specialized Expertise: Tailor agents for specific domains to increase accuracy and success rates.
- Reusability: Share agents across projects and teams for consistent, efficient processes.
- Flexible Permissions: Assign tool access individually to enhance security and focus.
Getting Started Quickly
Launching sub agents in Claude Code is intuitive:
- Access the sub agents interface using
/agents
. - Choose between project-level or user-level agents.
- Define your agent by drafting its purpose, customizing its description, and selecting necessary tools.
- Save your agent for automatic or manual invocation as needed.
How Sub Agents Are Configured
File Storage Locations
- Project sub agents: Located in
.claude/agents/
and take priority for that project.- User sub agents: Found in
~/.claude/agents/
and available across all projects.When names overlap, the project-level agent takes precedence.
Defining a Sub Agent
Each agent is defined in a Markdown file using YAML frontmatter, including:
- name: A unique, lowercase identifier (required).
- description: A clear summary of its responsibilities (required).
- tools: List of permitted tools (optional; omit to allow all).
- system prompt: Comprehensive instructions for the agent.
---
name: your-sub-agent-name
description: Description of when this sub agent should be invoked
tools: tool1, tool2, tool3 # Optional - inherits all tools if omitted
---
Your sub agent's system prompt goes here. This can be multiple paragraphs
and should clearly define the sub agent's role, capabilities, and approach
to solving problems.
Include specific instructions, best practices, and any constraints
the sub agent should follow.
Managing Permissions
Sub agents can be granted access to Claude Code’s internal tools or MCP tools. Limit permissions to only those necessary for the agent’s function for better security and relevance. Adjust permissions via the /agents
interface or by editing the config file directly.
Using and Managing Sub Agents
- Manage agents interactively with
/agents
: create, edit, delete, or adjust permissions. - For advanced setups, edit the configuration files directly.
Delegation Approaches
- Automatic: Claude picks the right agent based on your request and the agent’s description—be specific to encourage correct delegation.
- Explicit: Directly name the agent you want to use for a task, ensuring targeted execution.
Sub Agent Examples
- Code Reviewer: Offers prioritized, actionable feedback on code quality, security, and maintainability using tools such as Read, Grep, Glob, and Bash.
- Debugger: Focuses on troubleshooting and verifying solutions with Read, Edit, Bash, and Grep.
- Data Scientist: Specializes in SQL and BigQuery analysis, generating queries and presenting findings clearly with Bash, Read, and Write access.
Software Engineering Agents
Thank to Contains Studio a comprehensive collection of software engineering agent definitions are available to power your autonomous workflow in Claude Code.
Agents are automatically available in Claude Code. Simply describe your task and the appropriate agent will be triggered. You can also explicitly request an agent by mentioning their name.
Best Practices for Success
- Start with Claude-generated templates and refine as needed.
- Design agents for one clear responsibility each.
- Provide detailed instructions in the system prompt for each agent.
- Limit permissions to enhance security and maintain focus.
- Version control your project agents for collaborative development.
Advanced Features and Considerations
- Chaining: Link agents to create multi-step workflows, such as analysis followed by optimization.
- Dynamic Selection: Claude intelligently chooses agents based on context and clear descriptions.
- Performance: Sub agents support longer, more organized sessions, though each use involves a fresh context and may add slight latency.
Takeaway
Claude Code sub agents offer a powerful way to automate, specialize, and simplify your coding workflow. By integrating focused, reusable AI assistants, you can achieve greater efficiency, precision, and clarity—freeing your team to focus on higher-level challenges.
Streamline Your Coding Workflow with Claude Code Sub Agents