Track lessons
Claude CodeSubagentsIntermediate4 min

Configure Specialized Subagents in Claude Code

One agent reviewing security, performance and architecture at once can lose focus or fill its context with unrelated details. Specialized subagents get separate context windows and narrowly defined responsibilities.

When to use

  • Run several focused reviews in parallel after implementation.
  • Give a reviewer read-only tools while the main agent can edit.
  • Keep domain-specific review prompts reusable and isolated.

Example

After an authentication change, ask security-reviewer for trust-boundary issues while performance-reviewer checks repeated queries; merge only their evidenced findings.

TL;DR

A subagent is a Markdown file in .claude/agents/ with its own prompt and tool list.

Claude Code
/agents

Steps

  1. 1

    Create the file

    Define one responsibility, a specific trigger description and only the tools required to inspect the change.

    .claude/agents/security-reviewer.md
    ---
    name: security-reviewer
    description: Reviews diffs for auth, injection and secret leaks. Use after code changes.
    tools: Read, Grep, Glob, Bash
    ---
    
    You are a security reviewer. Read `git diff main...HEAD`.
    Report only real, exploitable issues with file:line, impact and fix.
    Never edit files.
  2. 2

    Choose the scope

    Commit project-specific reviewers with the repository, or keep general reviewers in your personal directory for use everywhere.

    paths
    .claude/agents/      # this project
    ~/.claude/agents/    # all your projects
  3. 3

    Call it explicitly

    Name the subagent and the target change when you need a deterministic review rather than automatic delegation.

    Claude Code
    Use the security-reviewer subagent on my current changes.
  4. 4

    Run several in parallel

    Ask independent reviewers to inspect the same diff concurrently, then have the main session deduplicate only findings supported by evidence.

    Claude Code
    Run security-reviewer, performance-reviewer and test-reviewer in parallel on this diff, then merge their findings.

Gotchas

  • Omitting tools gives the subagent every tool; list them for read-only reviewers.
  • Subagents start with a clean context; tell them exactly what to read.
  • The description decides automatic delegation; be specific.
  • Add model: to the frontmatter to pick a cheaper or stronger model per agent.

Cheat sheet

/agentsCreate and manage subagents
.claude/agents/<name>.mdProject subagent
tools: Read, GrepRestrict tools
model: <alias>Per-agent model

Related

Sources

Reviewing agent output? CodeCrab reviews pull requests locally with your own AI tools.