/review-security
The reference security-review command. Uses Opus for real analytical depth, walks OWASP Top 10 systematically, delivers severity-ranked findings with concrete exploitation scenarios. Read-only by design — run it aggressively without worrying about side effects.
opus/review-security is the highest-ROI slash command you can install — not because it runs most often (it doesn't), but because the failure mode it prevents is uniquely expensive. A single missed SQL injection or auth-boundary mistake can end a company. Even one caught vulnerability pays back the total cost of every code review this command will ever run, many times over.
The reference implementation on this page does three things a generic "review this for security" prompt wouldn't. It uses Opus, not Sonnet — because the token-cost delta is trivial compared to the tail risk of a missed critical issue. It walks the OWASP Top 10 systematically rather than doing an unstructured scan, so no category gets accidentally skipped. And it's read-only — the tool set is deliberately narrowed to Read, Grep, Glob so the command can never modify code while reviewing it. That constraint means you can run it aggressively without worrying about side effects.
Install this command on any repo that has production users. If you're on the fence, install it. The cost of running it is measured in cents; the cost of not running it and shipping a critical vulnerability is measured in the six figures.
The full /review-security definition
Save to .claude/commands/review-security.md. Note the model: opus line and the deliberately narrow read-only tool set — both are essential.
How to install
Almost always project-scoped so the security review reflects your team's threat model, not generic OWASP defaults.
Project scope Strongly recommended
Save to .claude/commands/review-security.md. Commit to git. Every teammate runs the same review with the same rules — consistency matters more here than for any other command.
User scope
Save to ~/.claude/commands/review-security.md. Only useful if you frequently review unfamiliar codebases (auditing, consulting). For your own team's code, project scope is much better.
Add your threat model Level up
For high-stakes systems, extend the command with a "Project-specific concerns" section listing your actual threat model: "Payment paths must never log full card numbers. Auth tokens must never appear in URLs. All admin endpoints require role check." Turns a generic scanner into your custom auditor.
How to use it
Works on a single file, a directory, a diff, or a specific PR. The narrower the scope, the deeper the review.
Alternative configs
Adjust for stricter enforcement, different threat models, or specific compliance needs.
🔴 CRITICAL VULNERABILITIES PRESENT — DO NOT MERGE on its own line, before any positive observations." Makes the go/no-go signal impossible to miss. Some teams pair this with a git hook that greps for that string in review output.Pairs well with
Security is a layered concern. Command for review, subagent for depth, hook for enforcement, MCP for context.
Common issues and fixes
The five issues teams hit most often with /review-security.
allowed-tools line is exactly Read, Grep, Glob, Bash(git diff:*), Bash(git log:*), Bash(git show:*). No Edit, no Write, no general Bash. Narrow allowed-tools is the safety mechanism — the command physically cannot modify code./review-security src/api/auth/, then /review-security src/api/payments/, rather than /review-security HEAD~20..HEAD. Smaller scopes get deeper reviews and cost the same per-line.1. Attacker sends request X. 2. System behavior Y. 3. Result Z."Other code review items
Same category, different job.
🐛 Hit an error?
AI Error Hub covers Claude Code errors and stack traces — cross-referenced with everything on this site.
Frequently asked questions
The questions developers ask most about /review-security.
Because the cost of a missed critical vulnerability dwarfs the cost delta between models.
Opus versus Sonnet for a typical security review is maybe 3-4 cents difference — negligible compared to what one caught SQL injection saves.
Sonnet is fine for /commit, /test-unit, and most everyday work. For consequential analytical work — security, architectural decisions, migration planning — always use Opus.
Because a security review command should never modify code.
The narrow allowed-tools (Read, Grep, Glob, plus git read commands) makes it physically impossible for the command to write, edit, or run arbitrary shell — even if Claude misinterprets a finding as something to auto-fix.
That guarantee is the whole point: you can run /review-security aggressively, on any code, without worrying about side effects. Fix suggestions go into the output; you apply them yourself.
Different strengths:
- SAST tools (Semgrep, CodeQL) — deterministic, fast, catch known-pattern vulnerabilities reliably.
/review-security— slower and probabilistic but reasons about context, business logic, and multi-file interactions.
Best practice: both. SAST in CI as a baseline gate, /review-security for higher-stakes changes and pre-release reviews. They catch different classes of issue.
Both, for different situations:
- Slash command — quick focused reviews (one file, one directory), results in your main conversation.
- Subagent — larger reviews with analysis in its own context window.
Many teams install both — /review-security for the fast case, security-reviewer subagent for delegated deep review.
The industry-standard categorization of the most critical web application security risks, maintained by the Open Web Application Security Project.
Using it as the review structure means:
- Findings are comparable across projects.
- Teams understand the categories.
- No category gets accidentally skipped.
Alternative structures (SANS Top 25, CWE Top 25) exist and are valid — OWASP wins on developer familiarity.
It marks them MEDIUM with a "needs verification" note rather than skipping (rule 5 in the reference config).
The alternatives are worse:
- Flag aggressively — creates noise.
- Silently skip — loses issues.
The "ambiguous MEDIUM" pattern gives the human reviewer a specific list of things to check with business context.
Yes, and it works well — OWASP Top 10 maps meaningfully to infra security (privileged containers, exposed secrets in manifests, missing network policies, insecure defaults).
For heavy IaC use, consider a dedicated /review-infra command that also walks:
- CIS benchmarks for the specific platform.
- Cloud-specific risks (public S3 buckets, over-permissive IAM policies, unencrypted volumes).
The general /review-security is still useful; the specialized version catches more.
Run it before opening the PR, not as a review step. The workflow:
/commit/review-security HEAD~5..HEAD- Address findings.
/pr-create
Front-loading the security review means issues get caught while the code is still fresh in your head, before human reviewers spend time on the same code, and before CI runs.
Add it to a suppressions section in the command body:
"Known findings to skip: (a) FILE:LINE — description — tracked as JIRA-123."
Do not globally suppress by category — you want new instances of the same category to surface.
Suppress specific lines with ticket references, so the suppression list is auditable and time-boxed.
Three cadences:
- Continuously on anything auth / payment / admin-related.
- Weekly on other changed code.
- Monthly on the whole codebase as an audit.
The continuous case is what pays off — high-stakes code gets a security lens on every touch. The weekly and monthly cases catch drift and cumulative risk.
Cost across all three is negligible; the cost of not running them until an incident is not.
Get the weekly Claude Code digest
Every Tuesday: new code review, Anthropic release recap, and the best community submission. 13,000+ developers read it.