c/agents › command
0votes

Claude Code subagent: code reviewer

TemplateLow risk Tested
submitted by CommandVault editors to c/agents · 2 uses

A .claude/agents/code-reviewer.md that reviews changes for bugs, risk and simplicity.

Template · 2 variables
---
name: code-reviewer
description: Reviews recent code changes for bugs, security issues and unnecessary complexity. Use after finishing a feature or before committing.
tools: Read, Grep, Glob, Bash
---

You are a senior engineer reviewing changes in {{project_name}}.

1. Get the changes: `git status --short` (new files don't show in `git diff` until added; read them in full), then `git diff` and `git diff --staged`, or the branch diff against {{base_branch}}.
2. For each change, check: correctness, error handling, security (auth, input validation, secrets), performance traps, missing tests.
3. Report only real issues, grouped as Bugs / Risky / Simplify, each with file:line, the problem and a concrete fix.
4. Do not edit files. End with: ship / ship after fixes / don't ship.
0 commentsreport

Guide

What you get: A read-only reviewer that reads your uncommitted diff and lists real bugs with file:line and a fix, then gives a ship / ship after fixes / don't ship verdict. Best for Developers using Claude Code (or Codex) who want a second look at a change before committing..

Before you start

  • A git repository with uncommitted or staged changes
  • Claude Code with project subagents in .claude/agents/ (or Codex with .codex/agents/)
  • Fill in project_name and base_branch

Worked example (Oct 17, 2026, Claude Code 2.1.296; Codex 0.151.0 (gpt-5.6-sol))

Input

Planted change in src/lib/pagination.ts (left uncommitted): a new hasNextPage(page, itemCount, pageSize) that returns `page <= totalPages(...)` (off by one: it says there is a next page on the last page) plus an unused `import { readFileSync } from "node:fs"`. Request: "Use the code-reviewer subagent to review my uncommitted changes."

Result

Claude Code: the code-reviewer subagent ran (confirmed in the log) and reported "hasNextPage is off by one, so 'Next' shows on the last page" at pagination.ts:15 with the fix `<` instead of `<=`, flagged the unused readFileSync import at :1, noted two older edge cases (NaN page size, negative page), and ended with "Verdict: ship after fixes." No files changed. Codex: on the second run it spawned the code-reviewer agent and reported the same two issues ("uses `<=`, so the final page ... incorrectly reports that another page exists") with "fix before shipping"; no files changed. Verified by hand: hasNextPage(3, 30, 10) returns true with the planted code.

Test project: fresh create-next-app (Next.js 16.4.2, TypeScript), Node 24.14.1. Blanks filled with project_name = "demo-app (Next.js 16 + TypeScript)". Claude Code: body saved as .claude/agents/<name>.md, run headless with `claude -p "Use the <name> subagent to ..." --permission-mode acceptEdits`. Codex: converted to .codex/agents/<name>.toml (name, description, developer_instructions) and run with `codex exec -m gpt-5.6-sol -s workspace-write "Use the <name> agent to ..."`. Subagent use was confirmed from Claude Code's stream-json log (Agent call with subagent_type) and from Codex session logs (spawn_agent with agent_type, and the agent's instructions present in the child session). Claude Code allowed tools: Bash(git diff *), Bash(git status *), Bash(git log *). On Codex's FIRST run the agent was not used: Codex followed a code-review skill installed in this user's Codex setup and spawned a generic helper (no agent_type); it still found both issues. A second identical run used the code-reviewer agent. So Codex picked up the agent in 1 of 2 runs. After this test step 1 also checks git status, so new untracked files get reviewed.

How to check it worked

  • Check the reviewer names the exact line of each bug and gives a concrete fix
  • Run `git status` afterwards: the reviewer should not have changed any files
  • Try one finding yourself (for example call the function with the failing input) before acting on it

Common problems

  • `git diff` and `git diff --staged` do not show brand-new untracked files, so a new file you never `git add`-ed will not be reviewed
  • In Codex, another installed review skill can take over and the agent may not be used; check that it says it used the code-reviewer agent
  • Codex ignores the `tools:` line, so the 'do not edit files' rule relies on the instructions alone there

Add this subagent to your AI tool

Converted for each tool's agent format. Fill in the blanks above first.

One command
npx commandvault add claude-code-subagent-code-reviewer-03274b7f --tool claude
Save as .claude/agents/code-reviewer.md
---
name: code-reviewer
description: Reviews recent code changes for bugs, security issues and unnecessary complexity. Use after finishing a feature or before committing.
tools: Read, Grep, Glob, Bash
---

You are a senior engineer reviewing changes in {{project_name}}.

1. Get the changes: `git status --short` (new files don't show in `git diff` until added; read them in full), then `git diff` and `git diff --staged`, or the branch diff against {{base_branch}}.
2. For each change, check: correctness, error handling, security (auth, input validation, secrets), performance traps, missing tests.
3. Report only real issues, grouped as Bugs / Risky / Simplify, each with file:line, the problem and a concrete fix.
4. Do not edit files. End with: ship / ship after fixes / don't ship.

Use it: Claude delegates to it when a task matches, or ask: "Use the code-reviewer subagent to …".

From Claude Code's docs , checked Oct 17, 2026.

More from c/agents

See all of c/agents →
0 comments

Log in to join the discussion.