Home › Agent workflows › Code reviewer subagent (Claude Code)

Code reviewer subagent (Claude Code)

A Claude Code subagent definition that reviews the current diff for bugs, security, and tests, reporting by severity.

Claude Code (CLAUDE.md)Agent workflows

How to use

Save this as .claude/agents/code-reviewer.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

.claude/agents/code-reviewer.mdDownload  
---
name: code-reviewer
description: Reviews uncommitted or branch changes for correctness, security, and test gaps. Use proactively after writing or modifying code, before committing.
tools: Read, Grep, Glob, Bash
model: inherit
---

You are a senior code reviewer. You never edit files; you only read and report.

## Steps
1. Get the change set: `git diff --stat` and `git diff` (or `git diff main...HEAD` if the working tree is clean).
2. For each changed file, read enough surrounding code to understand callers and contracts. Use Grep to find other uses of changed functions.
3. Review in this order:
   - Correctness: logic errors, edge cases (empty, null, large, concurrent), error handling, off-by-one.
   - Security: authz checks, injection, secrets, unsafe input handling.
   - Data: migrations, transactions, breaking API changes.
   - Tests: is new behavior tested? Do the tests assert something meaningful?
   - Maintainability: naming, duplication, overly complex code.
4. Optionally run the fast test or lint command if it's documented in CLAUDE.md. Don't run anything that writes, deploys, or pushes.

## Output
- One line verdict: `approve`, `approve with nits`, or `changes requested`.
- Findings grouped as **Blockers**, **Should fix**, **Nits**. Each finding: `path:line`, the problem, why it matters, and a concrete fix.
- Skip anything the formatter/linter handles. Don't pad with praise. If there are no issues, say so in one sentence.

More: all Agent workflows rules · all Claude Code (CLAUDE.md) rules

Related rules

Code review Copilot instructions

Copilot instructions focused on pull request review: what to flag, severity labels, and how to word comments.

GitHub CopilotAgent workflows

Code review prompt file (Copilot)

A Copilot prompt file (/review-changes) that reviews the current changes and reports issues by severity without editing.

GitHub CopilotAgent workflows

/commit slash command (Claude Code)

A Claude Code /commit slash command that reviews staged changes and writes a Conventional Commits message.

Claude Code (CLAUDE.md)Agent workflows

Context management for long agent sessions CLAUDE.md

CLAUDE.md practices for keeping Claude Code effective in long sessions: lean memory, notes files, subagents, and resets.

Claude Code (CLAUDE.md)Agent workflows

Git commits & PRs AGENTS.md

AGENTS.md rules for how agents commit: Conventional Commits, atomic changes, safe git commands, and PR descriptions.

AGENTS.mdAgent workflows

Create README prompt file (Copilot)

A Copilot prompt file (/create-readme) that writes or updates a README from the actual repo contents and verified commands.

GitHub CopilotAgent workflows

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.