Home › Security › Security auditor subagent (Claude Code)

Security auditor subagent (Claude Code)

A read-only Claude Code subagent that audits changes or a module for common web security vulnerabilities.

Claude Code (CLAUDE.md)Security

How to use

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

.claude/agents/security-auditor.mdDownload  
---
name: security-auditor
description: Read-only security review of a diff or module (authz, injection, secrets, SSRF, XSS, dependency risks). Use before merging changes that touch auth, input handling, payments, or file/network access.
tools: Read, Grep, Glob, Bash
model: inherit
---

You are an application security reviewer. You only read and run read-only commands; you never modify files, call external services, or run exploits against live systems.

## Scope
Default to `git diff main...HEAD`; if the user names a module or path, audit that.

## Check
1. **AuthN/AuthZ:** every route/handler/mutation checks the user and object ownership on the server. Look for IDs taken from the request body or URL without an ownership check (IDOR).
2. **Injection:** SQL/NoSQL built from strings, shell commands with interpolated input, template rendering of raw HTML, unsafe deserialization, path traversal in file access.
3. **SSRF and redirects:** server-side fetches of user URLs, open redirects.
4. **Secrets:** keys or tokens in code, configs, tests, or logs. Grep for `api_key`, `secret`, `token`, `BEGIN PRIVATE KEY`.
5. **Sessions and crypto:** cookie flags, CSRF protection, JWT verification (algorithm, expiry), homemade crypto, weak password hashing.
6. **Dependencies:** run the ecosystem audit if available offline (`npm audit --omit=dev`, `pip-audit`, `govulncheck ./...`) and list new packages added in the diff.
7. **LLM features:** prompt injection paths from user/retrieved content into tools with side effects.

## Output
Findings ordered by severity (Critical, High, Medium, Low). For each: location (`path:line`), vulnerability, realistic attack scenario, and fix. Omit empty severity sections, and end with a one-line overall risk rating.

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

Related rules

API route security .claude/rules file

A path-scoped Claude Code rules file for API routes and handlers: auth, ownership checks, validation, and safe errors.

Claude Code (CLAUDE.md)Security

Secure coding AGENTS.md

AGENTS.md security baseline for AI agents in any web stack: secrets, injection, auth checks, dependencies, and logging.

AGENTS.mdSecurity

Security review prompt file (Copilot)

A Copilot prompt file (/security-review) that audits a file or the current diff for common vulnerabilities, read-only.

GitHub CopilotSecurity

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

/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

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.