A Claude Code Subagent as a Code Reviewer

· 5 min read

A code reviewer is one of the best first subagents to write. The task is well defined, it benefits from fresh eyes with none of the context that produced the code, and it produces a short list you can act on. For a Flutter project it can check the things you keep correcting by hand: layering, generated files, strings, tests. This page shows the file format, a Flutter reviewer, and the limits you should know about. It uses Claude Code’s subagents documentation, read on the day this post was written. Check that page for the current format.

What a subagent is

The documentation says subagents “run in their own context window with a custom system prompt, specific tool access, and independent permissions.” Use one when a side task “would flood your main conversation with search results, logs, or file contents you won’t reference again: the subagent does that work in its own context and returns only the summary.” Reviewing a large change is a good fit: it reads many files and gives you a verdict.

Subagents are Markdown files with YAML frontmatter. Only name and description are required.

The documentation’s reviewer

Claude Code’s documentation includes a code reviewer as an example:

---
name: code-reviewer
description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.
tools: Read, Grep, Glob, Bash
model: inherit
---
You are a senior code reviewer ensuring high standards of code quality and security.

When invoked:
1. Run git diff to see recent changes
2. Focus on modified files
3. Begin review immediately

Review checklist:
- Code is clear and readable
- Functions and variables are well-named
- No duplicated code
- Proper error handling
- No exposed secrets or API keys
- Input validation implemented
- Good test coverage
- Performance considerations addressed

Provide feedback organized by priority:
- Critical issues (must fix)
- Warnings (should fix)
- Suggestions (consider improving)

Notice the documentation’s own caveat: it reviews code “without the Edit and Write tools. It can still change files through Bash.”

The frontmatter fields to know

  • name: a unique identifier.
  • description: when Claude should delegate to this subagent. “Claude uses each subagent’s description to decide when to delegate tasks”, so write it as a trigger.
  • tools: which tools it can use. If you leave it out, it inherits every tool available.
  • model: sonnet, opus, haiku, a full model ID or inherit.
  • disallowedTools, permissionMode, maxTurns, skills, hooks, memory: more control, described in the documentation.

Where to save it

Location Scope
.claude/agents/ The current project. Check it into version control
~/.claude/agents/ All your projects

A reviewer that encodes your project’s rules belongs in the project, so the whole team and every session gets the same reviewer.

A Flutter reviewer

Here is a project reviewer with a checklist drawn from the conventions in Flutter app architecture, Riverpod with Claude Code and CLAUDE.md for Flutter. The checklist is our suggestion:

---
name: flutter-reviewer
description: Reviews Flutter changes against this project's rules. Use after writing or modifying Dart code, before committing.
tools: Read, Grep, Glob
model: inherit
---
You review Flutter changes for this project. Read CLAUDE.md first.
Find the changes with the file list you are given; read each changed file.

Check each of these and report violations with the file and line:
1. Layering: widgets do not import data-layer or SDK packages; features do not import another feature's data folder.
2. State: `ref.watch` in build, `ref.read` only in callbacks; no logic in build methods.
3. Generated files (*.g.dart, *.freezed.dart) are not edited by hand.
4. Strings: no text literals in features; all user-facing text comes from localisation.
5. Every async screen handles loading, error and empty states.
6. Tests exist for new logic and for each new screen state.
7. No secrets, keys or debug leftovers.

Report as: Critical (must fix), Warnings, Suggestions. Do not edit any file.

This version has no Bash, so it cannot run commands or change files. The trade-off: it cannot run flutter analyze or the tests itself. Two ways to handle that:

  • Keep it read-only and have the main session run the analyzer and tests, passing the reviewer the output.
  • Add Bash and accept the risk, with a stricter prompt. If you do, remember it could change files through commands, so review what it did.

Invoke it

Claude can delegate automatically when a task matches the description. You can also ask directly: “Use the flutter-reviewer agent to review my changes.” The delegation appears in the transcript as a call to the subagent. If Claude cannot find a new subagent, the documentation says to restart Claude Code.

Using it well

  • Run it before you commit, on a change small enough to read.
  • Treat its findings as input. A reviewer can be wrong. Check each critical issue.
  • Keep the checklist short and specific. A long generic list produces generic feedback.
  • Add a line when it misses something you care about, and remove lines that never fire.
  • Do not make it the only reviewer. It is a first pass. The tests, the analyzer and a person remain.

What it is not

A subagent is not a guarantee. It is a model reading code, and it can miss things or flag non-issues. For rules that must hold every time, use a hook: see Claude Code hooks for Flutter. For a procedure you run on demand, use a skill: see how to write a Claude Code skill.

Where MobileKit fits

MobileKit uses subagents for whole stages: a researcher, a designer, a builder, a QA agent and a release gate whose job is to refuse a release that is not ready. A reviewer like the one above is the small version of the same idea. See Claude Code skills for mobile app development and Build a Flutter app with Claude Code.

Source read on the day this post was written: Claude Code: subagents.

Questions

What is a subagent?

Claude Code's documentation describes subagents as specialised assistants that each run in their own context window with a custom system prompt, specific tool access and independent permissions. They suit side tasks that would flood your main conversation with output.

Can a reviewer subagent change my files?

Not if you leave out the Edit and Write tools. But the documentation's own code reviewer example notes that without those tools it can still change files through Bash, so remove Bash too, or restrict what it can run, if you want it strictly read-only.

Where do I save a subagent?

In .claude/agents/ for a single project, which you can commit for your team, or ~/.claude/agents/ for all your projects.

Try it on your next idea

One payment, every update to this major version, and a refund window if it is not for you. Refund policy.