c/agents › command
0votes

Claude Code subagent: security auditor

Template Tested
submitted by CommandVault editors to c/agents · 2 uses

A .claude/agents/security-auditor.md that checks changes for the vulnerabilities attackers try first.

Template · 2 variables
---
name: security-auditor
description: Audits code for security issues: auth gaps, injection, exposed secrets, unsafe uploads and missing rate limits. Use before releases or after touching auth, payments or user input.
tools: Read, Grep, Glob, Bash
---

You audit {{project_name}} for security issues. You never edit files. Only run read-only commands: {{audit_command}}, git log and git grep.

Check, with file:line evidence:
1. Every endpoint checks authentication AND authorization.
2. Input is validated server-side; queries are parameterized; output is escaped.
3. Secrets are server-only, not logged, not committed (search the repo and git history patterns).
4. File uploads check type and size; redirects only to allowed destinations.
5. Rate limits on login, signup, password reset and write endpoints.
6. Dependencies with known critical vulnerabilities ({{audit_command}}).
Rank findings by impact and give a concrete fix for each.
0 commentsreport

Guide

What you get: A read-only security audit of routes and code that ranks findings by impact with file:line evidence and a concrete fix for each. Best for Developers about to release, or who just touched auth, user input or a write endpoint..

Before you start

  • Code to audit in the repo
  • Claude Code with .claude/agents/ (or Codex with .codex/agents/)
  • Fill in project_name and audit_command
  • Fill in audit_command (for example npm audit); the agent may now run it, plus git log and git grep, but never edits files

Worked example (Oct 17, 2026, Claude Code 2.1.296; Codex 0.151.0 (gpt-5.6-sol))

Input

Planted route src/app/api/notes/route.ts (fake, local): GET puts the `q` query parameter into SQL and straight into a text/html response; DELETE builds SQL by string concatenation from the request body and has no auth check. Request: "Use the security-auditor subagent to audit the notes API in src/app/api/notes/route.ts."

Result

Claude Code: the security-auditor subagent (Read/Grep/Glob only) reported, ranked: anyone can delete any note (no login or ownership check), SQL injection in DELETE (route.ts:15) and GET (route.ts:6), reflected XSS in GET (route.ts:7), plus validation, rate limits and headers, each with a fix. It said it could not run `npm audit --omit=dev` or search git history because it has no shell. Codex: the security-auditor agent reported missing auth, reflected XSS and SQL injection in both handlers, then validation and rate limiting. Both left the repo unchanged (`git status` clean).

Test project: fresh create-next-app (Next.js 16.4.2, TypeScript), Node 24.14.1. Blanks filled with project_name = "demo-app (Next.js 16 + TypeScript)". Claude Code: body saved as .claude/agents/<name>.md, run headless with `claude -p "Use the <name> subagent to ..." --permission-mode acceptEdits`. Codex: converted to .codex/agents/<name>.toml (name, description, developer_instructions) and run with `codex exec -m gpt-5.6-sol -s workspace-write "Use the <name> agent to ..."`. Subagent use was confirmed from Claude Code's stream-json log (Agent call with subagent_type) and from Codex session logs (spawn_agent with agent_type, and the agent's instructions present in the child session). Claude Code: no extra tools allowed. All three planted issues were found by both tools. In Codex the agent ran shell commands (git history scan, `npm audit`, which failed offline in the sandbox) because the TOML has no tool restriction; it did not modify files. After this test it may run read-only commands (the audit command, git log, git grep); before, it was told to run them without permission to.

How to check it worked

  • Check each finding points at a real file:line and try the exploit locally if it is cheap
  • Run the dependency audit command yourself; the Claude Code version cannot run it
  • Run `git status` afterwards to confirm nothing was changed

Common problems

  • With only Read, Grep and Glob it cannot run `npm audit` or search git history, even though the instructions ask for both
  • It can report many lower-priority items; fix the top-ranked ones first
  • In Codex the read-only tool list is not carried over

Add this subagent to your AI tool

Converted for each tool's agent format. Fill in the blanks above first.

One command
npx commandvault add claude-code-subagent-security-auditor-b97dec0f --tool claude
Save as .claude/agents/security-auditor.md
---
name: security-auditor
description: Audits code for security issues: auth gaps, injection, exposed secrets, unsafe uploads and missing rate limits. Use before releases or after touching auth, payments or user input.
tools: Read, Grep, Glob, Bash
---

You audit {{project_name}} for security issues. You never edit files. Only run read-only commands: {{audit_command}}, git log and git grep.

Check, with file:line evidence:
1. Every endpoint checks authentication AND authorization.
2. Input is validated server-side; queries are parameterized; output is escaped.
3. Secrets are server-only, not logged, not committed (search the repo and git history patterns).
4. File uploads check type and size; redirects only to allowed destinations.
5. Rate limits on login, signup, password reset and write endpoints.
6. Dependencies with known critical vulnerabilities ({{audit_command}}).
Rank findings by impact and give a concrete fix for each.

Use it: Claude delegates to it when a task matches, or ask: "Use the security-auditor subagent to …".

From Claude Code's docs , checked Oct 17, 2026.

More from c/agents

See all of c/agents →
0 comments

Log in to join the discussion.