Claude Code
authorKRIATIZ
03 · Extensions / lesson 2 of 4

Subagents

20 minIntermediate5 steps

A subagent is a separate helper with its own context, instructions and tool set. The main agent delegates part of the work and gets back only the result, so the main session stays clean.

data and requestsproblem
Lesson stepsstep 1 of 5
  1. Clutter
  2. Explorer
  3. Reviewer
  4. Tester
  5. Team
step 1 / 5problem

Exploration clutters context

Searching 2,000 files in the main session fills the context with hundreds of fragments.

Key point

The main session should stay clean.

← → steps · space pause · R restart · ⌘K search
You will learn 5
Lesson notes

Why subagents

  • Clean context. Exploring a big codebase can read hundreds of files. A subagent does that in its own context and returns a short conclusion.
  • Specialisation. Each subagent has its own instructions: a reviewer looks for bugs, a tester writes tests.
  • Restrictions. Give a subagent read-only tools and it physically can’t change code.
  • Parallelism. Several subagents can explore different parts of the project at once.

How to create one

The /agents command opens the subagent manager. Or create a file by hand:

.claude/agents/code-reviewer.md
---
name: code-reviewer
description: Reviews changes after implementation. Use after finishing a feature or before committing.
tools: Read, Grep, Glob, Bash
---

You are a reviewer. Look at git diff.
Look for: bugs, unhandled errors, missing tests, leaked secrets.
Return a list of issues with file and line. Don't change code.

How to call it

  • The agent decides on its own when to delegate if a subagent’s description matches the task.
  • Or ask directly: "have code-reviewer review the changes".

Useful subagents

SubagentTaskTools
Explorerfind where and how something is implementedread and search only
Reviewercheck the diff before a commitread, git diff
Testerwrite and run testsread, edit tests, bash
Doc writerupdate README and commentsread, edit

When you don’t need a subagent

  • The task is small and the context is clean anyway.
  • You need close step-by-step interaction: a subagent works autonomously and returns a result.
  • The subagent’s result would need lengthy explanation to the main session, cancelling the benefit.
Restrict tools. A reviewer that can’t edit won’t "fix" code on its own.

Ready-made subagents are in the article "Claude Code Subagents".

Today's task

Create a read-only reviewer subagent with git diff. After your next task, ask it to review the changes.

Want a team of subagents for your project?

I will set up subagents for review, tests, docs and code exploration for your stack.

Let’s talk
Vladyslav Koshelyev
Vladyslav Koshelyev

Developer at KRIATIZ. I build chatbots, websites and automation for businesses. Author of the course.

About the author · Telegram