Tech Update / Adventures with Claude Code #32

Your own subagent – a colleague made to measure

Part 1 asked when a subagent is the right choice. Since then the follow-up question has come up several times: "And how do I build one?"

With a single Markdown file.

📄 The file

.claude/agents/code-reviewer.md:

---
name: code-reviewer
description: Reviews changes for bugs, edge cases and our style guide. Use proactively after any larger change.
tools: Read, Grep, Glob
model: sonnet
---

You are an experienced reviewer. Check the diff for bugs,
missing edge cases and violations of our conventions.
Name file and line. No matters of taste.

The top part says when the agent works and with what. The text below is its system prompt. Checked into the project folder, the whole team has it. Under ~/.claude/agents/, only you do.

🧰 The most important settings

  • tools: what it may do. Leave it out and it inherits everything.
  • model: haiku for simple jobs saves tokens (part 17).
  • skills: skills it brings along from the start (part 3).
  • memory: project: its own notes across sessions.
  • isolation: worktree: works in a worktree of its own (part 8).

📣 Calling it

Claude delegates on its own when the task matches the description. To be explicit, use @ and the agent's name, or just say it: "Use the code-reviewer for the changes in the auth module." With claude --agent code-reviewer the whole session runs as that agent.

A word of caution:

The subagent doesn't see your conversation. It gets its prompt and the task, nothing more. Whatever it needs to know belongs in the file. And it uses tokens of its own, even though the main session stays lean. The quickest way to get the file, by the way, is to ask Claude to write it.

My rule of thumb:

  • Read-only? tools: Read, Grep, Glob.
  • The description says when. The prompt says how.
  • Check it in so the team has the same colleague.

← Back to overview