Chapter 35
35 / 38

Claude Code Sub-Agent Configuration

⏱️ 15 min

Claude Code supports creating specialized sub-agents, each focused on a specific domain. This chapter covers how to configure and use them.


What Are Sub-Agents

Sub-agents are AI assistants with specific expertise that Claude Code can call for particular task types. They live in .claude/agents/.

How They Differ from Commands

FeatureCommandsSub-Agents
TriggerManual /<command>Automatic or manual
ExpertiseGeneral tasksDomain-specific
PersistenceSingle executionContinuous conversation
Location.claude/commands/.claude/agents/

Agent File Structure

---
name: agent-name
description: Agent description -- Claude uses this to decide when to invoke
tools: Read, Write, Edit, Bash
color: blue
---

# Agent Title

You are a professional [role]...

## Your Expertise

...

## Workflow

...

7 Practical Sub-Agents

1. pr-reviewer - PR Code Review Expert

Professional code review agent focused on quality, security, and best practices.

Trigger scenario: Reviewing PRs, code quality checks

Config example:

---
name: pr-reviewer
description: Expert code reviewer for GitHub pull requests. Provides thorough code analysis with focus on quality, security, and best practices.
tools: Write, Read, Glob, Grep, Bash(gh:*), Bash(git:*)
color: blue
---

Review focus:

  • Code correctness - logic errors, edge cases, error handling
  • Project conventions - code style, naming, file organization
  • Performance impact - algorithm complexity, query efficiency, resource usage
  • Test coverage - test cases, edge tests, test quality
  • Security considerations - input validation, auth, data exposure risk

Output format:

  1. Critical Issues (must fix) - security vulnerabilities, functional bugs
  2. Important Suggestions (should fix) - performance issues, maintainability
  3. Minor Improvements (consider) - style inconsistencies, optimization opportunities

2. github-issue-fixer - Issue Resolution Expert

Dedicated to solving GitHub Issues.

Trigger scenario: Bug fixes, Issue resolution

Config example:

---
name: github-issue-fixer
description: GitHub issue resolution specialist. Analyzes issues, identifies root causes, and implements fixes.
tools: Read, Write, Edit, Glob, Grep, Bash(gh:*), Bash(git:*)
color: green
---

Workflow:

  1. Fetch and analyze Issue details
  2. Reproduce the problem
  3. Locate root cause
  4. Implement fix
  5. Verify fix
  6. Create PR

3. ui-engineer - UI/UX Development Expert

Professional frontend development agent focused on UI components and interfaces.

Trigger scenario: Frontend development, UI components, responsive design

Config example:

---
name: ui-engineer
description: Expert UI/frontend developer for creating, modifying, or reviewing frontend code, UI components, and user interfaces. PROACTIVELY use for UI/UX implementation.
tools: Read, Write, Edit, Glob, Grep, Bash, WebFetch
color: purple
---

Expertise:

  • Modern JavaScript/TypeScript
  • React, Vue, Angular frameworks
  • CSS-in-JS, Tailwind CSS
  • Responsive and mobile-first design
  • Component-driven architecture and design systems
  • State management (Redux, Zustand)
  • Performance optimization and bundle analysis
  • Accessibility (WCAG) compliance

Code quality standards:

  • Self-documenting code with clear naming
  • TypeScript type safety
  • SOLID principles
  • Reusable, composable components
  • Performance-optimized without sacrificing readability

4. instruction-reflector - Instruction Reflection

Analyzes and improves Claude Code instructions.

Trigger scenario: Optimizing CLAUDE.md, improving instructions

Config example:

---
name: instruction-reflector
description: Analyzes and improves Claude Code instructions based on session patterns.
tools: Read, Edit, TodoWrite, Bash(git:*)
color: yellow
---

Workflow:

  1. Review conversation history
  2. Check current CLAUDE.md
  3. Identify improvement opportunities
  4. Propose specific suggestions
  5. Implement approved changes

5. deep-reflector - Deep Session Analysis

End-of-session analysis agent that captures learnings and patterns.

Trigger scenario: Session review, knowledge extraction

Config example:

---
name: deep-reflector
description: Full session analysis and learning capture. Identifies patterns, insights, and improvement opportunities.
tools: Read, Write, TodoWrite
color: orange
---

6. insight-documenter - Insight Documentation

Records technical breakthroughs and important insights.

Trigger scenario: Recording technical discoveries, knowledge capture

Config example:

---
name: insight-documenter
description: Technical breakthrough documentation specialist. Captures and organizes insights for future reference.
tools: Read, Write, Edit
color: cyan
---

7. command-creator - Command Creation Expert

Helps create new Claude Code commands.

Trigger scenario: Creating custom commands

Config example:

---
name: command-creator
description: Expert at creating new Claude Code custom commands. Helps design and implement slash commands.
tools: Read, Write, Edit, Glob
color: pink
---

Creating Your Own Agents

Step 1: Create the Agent File

mkdir -p .claude/agents
touch .claude/agents/my-agent.md

Step 2: Write the Agent Config

---
name: my-agent
description: Agent description - Claude uses this to decide when to invoke
tools: Read, Write, Edit, Bash
color: blue
---

# My Professional Agent

You are a professional [role] focused on [domain].

## Your Expertise

-   Expertise area 1
-   Expertise area 2
-   Expertise area 3

## Workflow

1. Analyze requirements
2. Develop approach
3. Execute task
4. Verify results

## Output Standards

-   Use clear structure
-   Provide actionable recommendations
-   Include code examples (when applicable)

## Important Notes

-   Note 1
-   Note 2

Agent Config Parameters

ParameterDescriptionExample
nameAgent name (unique ID)"pr-reviewer"
descriptionDescription (determines when invoked)"Expert code reviewer..."
toolsAvailable tools list"Read, Write, Bash"
colorDisplay color"blue", "green", "purple"

Available Colors

  • blue - Blue
  • green - Green
  • purple - Purple
  • yellow - Yellow
  • orange - Orange
  • cyan - Cyan
  • pink - Pink
  • red - Red

Agents vs Commands vs Skills

FeatureCommandsAgentsSkills
TriggerManual /cmdAuto/manualAutomatic
ExpertiseMediumHighHigh
ComplexityLowMediumHigh
Files11Multiple
Best forQuick opsSpecialist tasksComplete workflows

Best Practices

1. Write Precise Descriptions

# Good description

description: Expert code reviewer for GitHub pull requests. Use when reviewing PRs for code quality and security.

# Bad description

description: Reviews code

2. Minimize Tool Permissions

# Good - only required permissions

tools: Read, Glob, Grep, Bash(gh:\*)

# Bad - overly broad

tools: Read, Write, Edit, Bash, WebFetch, TodoWrite

3. Define Clear Workflows

## Workflow

### 1. Information Gathering

-   Gather necessary context
-   Understand task scope

### 2. Analysis Phase

-   Deep-dive into the problem
-   Identify key points

### 3. Execution Phase

-   Implement solution
-   Verify results

### 4. Output Phase

-   Organize results
-   Provide recommendations

4. Set Appropriate Expertise Scope

Agents should focus on one domain -- don't make them generalists.


ScenarioRecommended Agent
Code reviewpr-reviewer
Bug fixinggithub-issue-fixer
Frontend devui-engineer
Instruction tuninginstruction-reflector
Knowledge captureinsight-documenter

Reference: feiskyer/claude-code-settings

📚 Related resources

Common questions

Open a question to review the practical answer.

How are Claude Code Agents different from Commands?

Four-axis difference: (1) trigger — Commands need manual `/<cmd>`, Agents can be auto-invoked by the AI; (2) specialisation — Commands are general purpose, Agents own a domain (e.g. `ui-engineer` only does frontend); (3) persistence — Commands run once, Agents can hold a conversation; (4) location — Commands in `.claude/commands/`, Agents in `.claude/agents/`.

Why does the Agent description field decide invocation?

Because Claude routes on it. A vague description ("Reviews code") yields poor matches; a precise one ("Expert code reviewer for GitHub pull requests. Use when reviewing PRs for code quality and security") tells the AI exactly when to dispatch it. The chapter suggests adding the keyword PROACTIVELY (e.g. "PROACTIVELY use for UI/UX implementation") to nudge AI into auto-invoking.

How do I use pr-reviewer's three severity levels?

Critical Issues are must-fix (security vulnerabilities, functional bugs) — block merge until resolved; Important Suggestions are should-fix (performance, maintainability) — fine to defer to a follow-up issue but must be tracked; Minor Improvements are nice-to-have (style nits, optimisation hints) — non-blocking, author's call. The 3-tier split keeps reviews strict without choking release cadence.

How do I pick between Agents, Commands, and Skills?

Pick by complexity and trigger: (1) Command — low complexity, single file, manual `/cmd`, quick ops (lint, translate); (2) Agent — medium complexity, single file, auto or manual, specialist tasks (PR review, UI work); (3) Skills — high complexity, multi-file packages, AI-decided, full workflows (deployment pipeline, spec-driven dev). Simple to complex: Command < Agent < Skills.

What is the right way to scope an Agent's tools?

Principle of least privilege. The chapter's contrast: good — `tools: Read, Glob, Grep, Bash(gh:*)` (pr-reviewer only needs to read code and call gh); bad — `tools: Read, Write, Edit, Bash, WebFetch, TodoWrite` (everything wide open). The former contains failures, the latter has uncontainable blast radius if prompt injection lands. Rule of thumb: do not grant Write unless required.