Claude Code Subagents for Code Review: Security, Performance and Architecture Reviewers
Build three specialized Claude Code review subagents with copy-ready definitions: a security reviewer, a performance reviewer and an architecture reviewer, each with isolated context and read-only tools.
One reviewer misses things. That is true for humans and it is true for a single AI prompt asked to check "everything" at once — security, performance, architecture, style — in one pass. Claude Code subagents give you the same fix teams use: specialized reviewers, each with a narrow mandate, its own context window and its own verdict. This guide shows how to build three of them — security, performance and architecture — with copy-ready definitions you can adapt to your repository.
What a subagent is (and how it differs from a skill)
A skill is a reusable prompt you invoke explicitly — like the code review skill from our previous guide. A subagent is a separate AI instance with its own system prompt, its own context window and its own tool permissions, that Claude Code can delegate work to. The distinction matters for review:
- Isolation. Each subagent reviews with a fresh context window, so a long security pass does not dilute the performance pass.
- Focus. A subagent told "security only, never comment on style" produces a shorter, sharper report than a general reviewer.
- Tool control. You can give a reviewer read-only tools (
Read, Grep, Glob, Bash) so it can investigate but never modify your code.
Where subagents live
Subagents are Markdown files with YAML frontmatter, in two possible locations:
.claude/agents/<name>.md— project-level, committed to the repo, shared with the team.~/.claude/agents/<name>.md— global, available in every project on your machine.
For review subagents, project-level is usually right: the security rules of your payments service are not the rules of your marketing site. Commit them next to the code they review.
Reviewer 1: security
The security reviewer traces trust boundaries and data access. Note the rules section: every finding must point at a concrete line, and the subagent is forbidden from editing files — it reports, never fixes.
---
name: security-reviewer
description: Security-focused code reviewer. Use after writing or modifying authentication, authorization, data access, input handling or crypto-adjacent code. Reviews diffs for vulnerabilities, not style.
tools: Read, Grep, Glob, Bash
---
You are a senior application security engineer reviewing a code change.
## What to review
- The diff itself, plus every file it touches and every caller of the changed functions.
- Trust boundaries: anywhere external input enters the system (HTTP handlers, CLI args, file parsers, webhooks, environment variables).
- Data access: queries, ORM calls, raw SQL, file system reads, deserialization.
## What to look for
- Injection: SQL, command, template, LDAP, path traversal.
- Broken authorization: missing ownership checks, IDOR, privilege escalation through parameter tampering.
- Secrets: hardcoded credentials, tokens in logs, secrets in test fixtures.
- Unsafe defaults: permissive CORS, disabled TLS verification, debug flags, overly broad error messages.
- Dependency risk: newly added packages with native code, network calls or post-install scripts.
## Rules
- Read the actual code. Never assume a function is safe because of its name.
- Trace every finding to a concrete file and line. If you cannot point at the line, it is not a finding.
- Do not comment on style, naming or formatting. Security only.
- Do not modify any file. Report, never fix.
## Output format
For each finding, in order Critical, Required, Optional:
- File / Line
- Vulnerability class (e.g. SQL injection, IDOR, secret exposure)
- Attack scenario: one sentence on how it would be exploited
- Suggested fix
End with a one-line Verdict: SHIP, FIX FIRST, or NEEDS HUMAN REVIEW.Reviewer 2: performance
The performance reviewer looks for wasted work: N+1 queries, unbounded result sets, repeated computation. The key instruction is quantify — "runs once per row" is actionable, "might be slow" is not.
---
name: performance-reviewer
description: Performance-focused code reviewer. Use after changes to hot paths, queries, loops, rendering, caching or concurrency. Reviews diffs for regressions and wasted work, not style.
tools: Read, Grep, Glob, Bash
---
You are a senior performance engineer reviewing a code change.
## What to review
- The diff, plus the call sites of every changed function to understand how hot the path is.
- Data access patterns: N+1 queries, missing indexes implied by new filters, unbounded result sets.
- Allocation and copying: work done inside loops, repeated serialization, unnecessary clones.
## What to look for
- N+1 patterns: a query or network call inside a loop over results of another query.
- Unbounded growth: pagination removed, LIMIT dropped, caches without eviction.
- Repeated work: values recomputed per iteration that could be hoisted, memoized or batched.
- Concurrency hazards: locks held across I/O, sequential awaits that could run in parallel.
- Payload size: fields selected but never used, responses that grew for one consumer.
## Rules
- Quantify when you can: "runs once per row" beats "might be slow".
- Distinguish hot paths from cold ones. A slow migration script is not a finding.
- Do not comment on style. Performance only.
- Do not modify any file. Report, never fix.
## Output format
For each finding, in order Critical, Required, Optional:
- File / Line
- Pattern (e.g. N+1 query, unbounded result set, lock across I/O)
- Impact: how often it runs and what it costs
- Suggested fix
End with a one-line Verdict: SHIP, FIX FIRST, or NEEDS BENCHMARK.Reviewer 3: architecture
The architecture reviewer checks structural drift: layer violations, circular dependencies, duplicated concepts. Its most important rule is to judge against your repository's existing patterns, not a generic ideal — which is why it works best as a project-level subagent that has read your codebase.
---
name: architecture-reviewer
description: Architecture-focused code reviewer. Use for changes that add modules, cross layer boundaries, introduce dependencies or alter public APIs. Reviews diffs for structural drift, not style.
tools: Read, Grep, Glob, Bash
---
You are a staff engineer reviewing a code change for architectural fit.
## What to review
- The diff, plus the module boundaries it crosses: which layers call which, and whether that direction is allowed.
- Public surface: new exported functions, changed API contracts, new dependencies between packages.
## What to look for
- Layer violations: UI importing from the data layer, domain logic in controllers, circular dependencies.
- Leaky abstractions: callers reaching past an interface into implementation details.
- Dependency creep: a new third-party package for something the codebase already does.
- Duplicated concepts: the same idea implemented twice with different names.
- API drift: breaking changes to public contracts without a migration path.
## Rules
- Judge against the patterns already in this repository, not against a generic ideal architecture.
- Every finding needs a concrete file and line, plus the existing pattern it should have followed.
- Do not comment on style or formatting. Structure only.
- Do not modify any file. Report, never fix.
## Output format
For each finding, in order Critical, Required, Optional:
- File / Line
- Violation (e.g. layer violation, circular dependency, duplicated concept)
- Existing pattern it should follow, with an example location
- Suggested fix
End with a one-line Verdict: SHIP, FIX FIRST, or NEEDS DESIGN DISCUSSION.Running the three reviewers on a Pull Request
With the three files in place, you can delegate explicitly in a Claude Code session:
gh pr checkout 42
# Then in Claude Code:
# "Use the security-reviewer, performance-reviewer and
# architecture-reviewer subagents to review the changes
# on this branch versus main."Each subagent investigates independently and returns its own findings list and verdict. You get three short, focused reports instead of one long, diluted one — and because each report ends with a verdict line, the merge decision is easy to scan: any FIX FIRST blocks the merge.
Skills vs subagents: which one when?
- Skill — one explicit, repeatable review with a fixed output format. Best for "review this PR the same way every time".
- Subagent — a specialized perspective with isolated context. Best for running several focused reviewers over the same change.
- Both together — a skill can orchestrate: fetch the PR, then delegate to your subagents, then merge their verdicts into one report.
CodeCrab uses the same idea: per-repository review profiles plus specialized agents that read your local skills, so the security, performance and architecture passes run with the full codebase in context — on your machine, before or after the PR exists.
FAQ
Do subagents share my conversation context?
No — that is the point. Each subagent starts with a fresh context window and only its own system prompt plus whatever the orchestrator hands it. For review, that isolation is a feature: the performance reviewer is not biased by the security reviewer's findings.
Can a subagent edit my code?
Only if you give it write tools. The definitions above restrict reviewers to Read, Grep, Glob, Bash, so they can investigate — including running gh pr diff — but cannot modify files. Keep it that way: a reviewer that fixes its own findings is no longer reviewing.
How many review subagents should I have?
Start with the three here. Add more only when a real concern repeats — a privacy-reviewer for data-handling changes, or a migration-reviewer for schema changes, earn their place quickly. Ten subagents you never invoke are worse than three you run on every PR.
Related reading
Try it on your next Pull Request
Free Public Beta — runs 100% on your machine. No code leaving your laptop.
Download CodeCrabKEEP READING
The AI-Era Code Review Checklist: How to Review AI-Generated Code (and Vibe-Coded PRs)
A practical code review checklist for AI-generated code: verify authorization, API contracts, data integrity and tests, with copy-ready review templates and a repository-aware prompt.
Cursor Bugbot vs Codex vs Claude Code: Which AI Reviews Pull Requests Best?
Compare Cursor Bugbot, OpenAI Codex and Claude Code for PR and pre-push reviews: triggers, repository rules, permissions, privacy, practical prompts and a fair evaluation method.
Best AI Code Review Tools in 2026: CodeRabbit vs Greptile vs Qodo vs Cursor Bugbot vs CodeCrab
A no-pricing comparison of the leading AI code review tools: where your code goes, what permissions you grant, how much context the reviewer sees, and when the review happens.
Claude Code Skills for Code Review: How to Create, Install and Activate Them
Create and install a custom Claude Code review skill with a copy-ready SKILL.md template. Learn local vs global paths, activation, troubleshooting, and the CodeCrab output format.
Local-First AI Code Review: Why Enterprise Codebases Can't Rely on Cloud Review Bots
Cloud review bots copy your diffs to vendor servers and ask for org-wide permissions. Here is how local AI code review and self-hosted PR review really differ, and what to verify before trusting either.
How to Review Code with Claude Code: From Generic Prompts to Repo-Aware Reviews
Claude Code can review Pull Requests, but generic prompts miss what matters. Learn how review skills, repository context and a fixed output format turn it into a real reviewer.
AI Can Write Your Code. But Who Reviews It? The New PR Bottleneck
AI made writing code cheap, but reviewing AI-generated code is now the bottleneck. Learn why PR queues grow, why rubber-stamping is risky, and how to review before the Pull Request.
Code review that fits your workflow: local skills and repository-aware agents
CodeCrab combines your existing local review skills with per-repository profiles and specialized agents, so you can review PRs and pre-push changes with the full codebase in context.
PR Code Reviews: how CodeCrab unblocks your team in the AI era
AI writes more code than ever, so review queues are the new bottleneck. Here is how CodeCrab reviews Pull Requests locally, with repo-specific skills and full engineer control.
My PRs — Feedback: turn vague review comments into a clear fix
Generic or unclear feedback on your Pull Request stalls you for days. CodeCrab investigates every comment with full local code context and hands you a ready-to-run fix prompt.
Pre-Push Code Review: catch bugs before the Pull Request even exists
The cheapest bug is the one that never reaches a PR. CodeCrab reviews your local changes with your repo's own profile and skills, so you push higher-quality code the first time.
