/review-security — Claude Code Slash Command for OWASP Security Reviews | AI Code Toolkit
Highest-ROI commandModel: OpusRead-onlyOWASP Top 10

/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.

Category
Code Review
Model
opus
Tools
Read-only
Cost per run
~$0.15
Updated
Aug 2026

/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 Config

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.

markdown .claude/commands/review-security.md
--- allowed-tools: Read, Grep, Glob, Bash(git diff:*), Bash(git log:*), Bash(git show:*) description: Security review against the OWASP Top 10, with severity-ranked findings model: opus argument-hint: [path or diff spec, optional focus e.g. "auth"] --- # Context - Target: $ARGUMENTS - Recent related commits: !`git log --oneline -10 -- $ARGUMENTS 2>/dev/null || git log --oneline -10` # Task Conduct a security review of the target. Walk the OWASP Top 10 systematically: 1. Broken Access Control — missing authorization checks, IDOR, privilege escalation 2. Cryptographic Failures — weak crypto, plaintext secrets, missing TLS, poor key management 3. Injection — SQL, NoSQL, command, LDAP, template, header injection 4. Insecure Design — missing rate limits, no CSRF protection, unsafe defaults 5. Security Misconfiguration — verbose errors, default credentials, unnecessary features enabled 6. Vulnerable Components — outdated deps with known CVEs (call out but don't fix) 7. Authentication Failures — weak passwords, session fixation, missing MFA paths 8. Data Integrity Failures — unsigned updates, unsafe deserialization 9. Logging & Monitoring Failures — missing audit logs on sensitive ops, PII in logs 10. SSRF — unvalidated outbound requests, cloud metadata endpoint exposure Rules: 1. Rank findings by severity: CRITICAL, HIGH, MEDIUM, LOW, INFO. 2. Each finding: file:line, description, exploitation scenario, remediation. 3. Do NOT flag test fixtures, example code in docs, or code inside **/example/ paths. 4. Do NOT propose refactors that go beyond the security concern. 5. If a finding is ambiguous (could be safe given unseen context), mark it MEDIUM with a "needs verification" note rather than skipping. 6. If $ARGUMENTS includes a focus area, weight the review toward that but do not skip the other categories. # Output Structure the report: - Summary: counts by severity + one-line verdict - Critical + High findings (detailed) - Medium findings (grouped by category) - Low + Info (bulleted, no detail) - Positive observations (2-3 things the code does well — not filler; genuine)
Install

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.

Usage

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.

/review-security src/api/auth/
Directory-scoped review. Command reads every file in the auth directory and walks the OWASP Top 10 against them. Best for auth code, payment flows, admin endpoints — the highest-stakes areas.
/review-security src/api/users/route.ts
Single-file review. Deepest inspection because Claude can dedicate full attention to one file's context. Good for reviewing a specific endpoint before it ships.
/review-security HEAD~5..HEAD input validation
Diff-scoped review with focus. Reviews everything changed in the last 5 commits, weighted toward input validation. Useful for pre-merge review of a feature branch.
/review-security src/api/payments/ auth boundaries
Directory + focus. The focus keyword biases the review without narrowing it — other categories still get checked, but authorization findings get weighted higher.
/review-security src/lib/serialize.ts data integrity
Focused single-file review of code that handles deserialization. Command specifically hunts for unsafe deserialization patterns while still walking the full OWASP list.
Variations

Alternative configs

Adjust for stricter enforcement, different threat models, or specific compliance needs.

Strict mode (blocks on critical)
For pre-merge review in high-stakes repos
Add rule: "If any CRITICAL finding exists, end the response with 🔴 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.
Compliance-focused variant
For teams under PCI-DSS, HIPAA, or SOC2
Add a section: "Additionally check for: PCI-DSS violations (card data logging, weak TLS ciphers), HIPAA violations (PHI in logs, missing access audit), SOC2 concerns (missing change control, insufficient access review)." Layers compliance-specific concerns on top of OWASP baseline.
AI/LLM-specific variant
For codebases with LLM prompts and tool calls
Add category 11: "Prompt Injection — unvalidated user input reaching LLM prompts, unsafe tool invocation from LLM output, prompt exfiltration via crafted inputs." Increasingly essential for any product with LLM features.
Troubleshooting

Common issues and fixes

The five issues teams hit most often with /review-security.

Too many false positives — every review is 20 items long
The base OWASP walk flags speculative issues without enough project context, especially in codebases with existing safeguards (a global auth middleware, a validation library).
Add project context to the command: "This project uses which handles CSRF automatically. Input validation runs through at the router level. Do not flag missing validation on route handlers unless it's a specific bypass." Explicit safeguards eliminate noise.
Real issues get missed
The OWASP structure is comprehensive but generic. Project-specific attack surfaces (custom protocols, unusual auth flows, novel data handling) don't map cleanly to standard categories.
Add a "Project-specific concerns" section with your actual threat model: "Payment paths must never log full card numbers. Webhook endpoints validate signatures before parsing. Admin endpoints check role on every request." Encodes what generic OWASP scans miss.
Command tries to modify files during review
Model reached for Edit/Write despite the allowed-tools restriction, or the restriction wasn't set.
Confirm the frontmatter 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 takes too long on large diffs
Diff-scoped review with a large diff makes Opus read everything sequentially. This is inherent to review depth — nothing to fix without sacrificing coverage.
Break the review into smaller chunks: /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.
Findings feel formulaic — same shape every review
The OWASP structure creates a template shape. Some teams read this as low-quality output when it's actually consistent output.
Consistency is the feature, not a bug — you want to be able to compare reviews over time. If the output feels shallow specifically, deepen the exploitation-scenario field. Change rule 2 to: "For every finding, describe the attack in concrete steps: 1. Attacker sends request X. 2. System behavior Y. 3. Result Z."

🐛 Hit an error?

AI Error Hub covers Claude Code errors and stack traces — cross-referenced with everything on this site.

Visit AI Error Hub →
FAQ

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:

  1. /commit
  2. /review-security HEAD~5..HEAD
  3. Address findings.
  4. /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.