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:
- The files it reads and the searches it runs don’t fill up the main conversation;
- When it finishes, it only returns its conclusions;
- Several subagents can run at the same time.
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:
- A component navigated itself to an external site, but the parent page kept sending it data;
- The sensitive-word check only scanned the first 20,000 characters, while the code allowed up to 100,000;
- One path changed a data column but didn’t rewrite the components that depend on that column name.
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:
- the goal;
- where to look (files, directories, docs);
- what has already been ruled out, so it doesn’t repeat work;
- what format to return (conclusions, line numbers, a maximum length).
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:
- your team’s development rules (comment format, change logs, commit message format);
- fixed workflows (releases, blog posts, report generation);
- operations that need supporting scripts.
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
- Make the description clear about when to use it and when not to. This decides whether it gets triggered by mistake. For rule-type Skills, it’s best to set it to “only use when the command is entered manually”.
- State the reason behind each rule. As with
CLAUDE.md, including the “why” leads to more accurate execution. - Use scripts wherever you can: put deterministic steps (creating tables, calling APIs) into scripts in the Skill directory. That’s more reliable than having the AI write them fresh every time.
V. When not to use a subagent
- Anything you can look up with a command or two is faster to check yourself;
- Anything that needs back-and-forth discussion with you stays in the main conversation;
- Verify a subagent’s conclusions. A subagent saying “no problems” doesn’t mean there are none.