Claude Code tutorials · Part 04

Subagents and Skills

Use subagents to work in parallel and do an “unbiased” code review; turn the workflows your team repeats into Skills.

I. What is a subagent

A subagent is “another Claude” that the main session hands work off to. It has its own independent context:

II. The three situations where subagents pay off most

1. Broad searches and research

Have a subagent search the whole repo for where the export utility class is called, and what data each call exports. Return only “file:line + one-sentence description”.

The main conversation doesn’t have to absorb hundreds of lines of search results.

2. Independent code review (most recommended)

When you review your own code, it’s easy to follow your own line of thinking and miss problems. Have the subagent look only at the code, not at your conclusions:

Dispatch a review subagent. Give it only the changed diff and the new files, and don’t tell it our design conclusions.
Have it look for: security issues, concurrency / state issues, and anything that would throw an error at runtime.
For each item, give the file and line number, the failure scenario, and a suggested fix.

In practice, one round of review like this turned up 13 issues, several of them well hidden:

Check each finding against the code before fixing it. Confirm it is real first, and don’t accept everything at face value.

3. Parallel independent tasks

Several tasks that don’t depend on each other can be handed to multiple subagents at once. For example, you can research three reference implementations at the same time, or add tests to three modules at the same time.

III. How to write a subagent prompt

A subagent only knows what you write to it, so spell out the following clearly, the same way you would when handing work to a colleague:

IV. Skills: locking in repeated workflows

A Skill is an instruction file kept in .claude/skills/<name>/SKILL.md that tells Claude which steps and which scripts to use for a given kind of task. Good candidates include:

A minimal Skill:

---
name: team-dev-rules
description: Team development rules. Only use when the user types /team-dev-rules.
---

# Team development rules

1. When changing existing core logic, add a comment at the change stating the reason and the date.
2. For every change, append one entry to the end of the module’s change log, and list new files separately.
3. Commit message format: type: brief description (e.g. fix: fix login returning a 500 error)
4. If a piece of logic is called in two places, extract it into a shared method.
5. Split any method longer than 50 lines.

To use it, type /team-dev-rules, and it will check the current changes against this rule set item by item.

Lessons from writing Skills

V. When not to use a subagent