Security reviewer subagent for branch diffs
A Claude Code subagent that reviews the changes on a branch for exploitable security issues (injection, broken access control, secrets, SSRF, path traversal, unsafe deserialization, weak crypto) and reports each with an attack scenario and fix.
Agent in Security by AISkillHub Library
What it does
This subagent runs in its own context window so a security pass does not crowd out the main conversation. Claude Code delegates to it when you ask for a security review of your changes, or you can call it by name.
**Scope** It reviews the diff of the current branch against its base, plus the code paths those changes touch. That keeps the review focused on what is about to ship, rather than producing a generic audit of the whole repository.
**What it looks for** - Injection: SQL, NoSQL, shell commands, template injection, LDAP, header injection. - Broken access control: missing authorization checks, object IDs taken from the request without ownership checks (IDOR), mass assignment. - Authentication and sessions: token handling, cookie flags, password reset flows. - SSRF and open redirects from user-supplied URLs. - Path traversal and unsafe file uploads. - Unsafe deserialization and `eval`-like calls. - Secrets committed in code or config, and sensitive data in logs. - Cryptography misuse: home-made crypto, weak hashes for passwords, static IVs, non-constant-time comparisons of secrets. - Dependencies added in the diff that are unmaintained or unexpected.
**Report format** Each finding includes severity, `file:line`, a concrete attack scenario (who sends what, and what they gain), and a fix. Findings it cannot confirm by tracing data flow are marked as "needs verification" with what to check.
**What it will not do** It is read-only: its tool list excludes Edit and Write, and its instructions limit Bash to read-only git commands. It does not run scanners, exploit anything, or make network requests. It is not a substitute for a penetration test or a full threat model.
How to use it
1. Save the file below as `.claude/agents/security-reviewer.md` in your repository (or `~/.claude/agents/` for all projects). 2. Restart Claude Code or run `/agents` to confirm it is listed. 3. Ask: "Use the security-reviewer agent on this branch" or "security review my changes before I open the PR". 4. To compare with a base other than `main`, say so in the request. 5. The agent uses the `opus` model alias for deeper reasoning. Change `model:` to `sonnet` if you prefer speed or lower cost, or remove the line to use your session's model.
Files
Save each file at the path shown, relative to your project root.