/quality-gates:security-code-auditfrom quality-gates
Audits code for security vulnerabilities: input validation, secrets handling, authentication, SQL injection, XSS, and authorization. Activates when writing or reviewing security-sensitive code.
Ships in quality-gates. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
When writing code, follow Rules when writing. When reviewing, run Steps.
role, ownerId, price, isAdmin arrive that way).where id = ? and owner_id = session.userId), never by id alone.eval, new Function, pickle, yaml.load (use safe_load) or deserialise class instances from input..env.example with an empty value, and check .env* (except .env.example) is in .gitignore.|| "dev-secret" ships that default to production. Fail at startup when a required secret is missing.NEXT_PUBLIC_, VITE_, EXPO_PUBLIC_, REACT_APP_, or in any file the client imports. Service-role and admin keys never leave the server.Authorization or Cookie headers, full request bodies or tokens. Redact before logging.login-and-access: who signs in, how long they stay in, and what each person can see.crypto.randomBytes(32), secrets.token_urlsafe(32)), never Math.random or uuid v1. Compare secrets with a constant-time compare.HttpOnly, Secure, SameSite=Lax or stricter.verify=False, rejectUnauthorized: false, NODE_TLS_REJECT_UNAUTHORIZED=0).Audit the change, not the whole repository. Follow each piece of untrusted input from where it enters to where it is used. A finding needs a concrete attacker, action and gain; without one it is hardening advice.
For planning before launch (attack surface, launch checklist, pen test scope), use threat-model. For a whole-codebase audit or pen test, use a full audit skill (security-audit) if one is installed.
git diff plus staged) or the files named, and the code they call.npm audit, pnpm audit, pip-audit, semgrep, gitleaks). Do not install tools. With no secret scanner, search the added lines of git diff HEAD -U0 for key-shaped text (api key, secret, passw, token, bearer, a PRIVATE KEY header, and the prefixes AKIA, sk_live_, ghp_, xoxb-, xoxp-), then read each hit (most are names, not values).| Area | Ask |
|---|---|
| Authorisation | Does every query filter by the caller's own id or tenant? Can changing an id in the request reach another user's row? Is the check on the server, on every route, including the new one? |
| Authentication | Is the token verified (signature, algorithm, expiry, audience)? Session fixed on login, cleared on logout? Reset and invite tokens single-use and expiring? |
| Injection | Any query, shell command, path, template or regex built by joining strings with input? Object merge that allows __proto__? |
| Input | Schema validation at the boundary, with size limits? Does the handler accept fields the user must not set (role, owner id, price)? |
| Output | Raw HTML (dangerouslySetInnerHTML, v-html, innerHTML)? href or redirect target taken from input? |
| Server-side requests | Does the server fetch a URL the user supplies? Are internal addresses blocked? |
| Secrets | Hard-coded, logged, returned in an error, or shipped to the browser (NEXT_PUBLIC_, VITE_)? A fallback default (|| "dev-secret")? New name missing from .env.example? |
| Crypto | Math.random for tokens? Fast hash for passwords? === on secrets instead of a constant-time compare? Home-made schemes? |
| Browser | Cookie flags (HttpOnly, Secure, SameSite)? CSRF on state-changing cookie-auth routes? CORS reflecting any origin with credentials? |
| Files | Upload type, size and name checked on the server? Stored outside the web root? Path built from input? |
| Webhooks | Signature verified on the raw body? Replay window? |
| Abuse | Rate limit on login, reset, signup and costly endpoints? |
| Database | Row-level security on tables exposed to clients? Service-role key used where a user key should be? |
| Dependencies | New package: known advisories, a look-alike name, an install script? |
| AI features | Can untrusted text reach a model that holds tools or secrets? Is model output used as HTML, SQL or a command? |
<file>:<line> [SEVERITY] <weakness>
Path: <entry point> -> <sink>
Exploit: <who> does <what> and gains <what>
Fix: <the change, at most 10 lines>
## Verdict: PASS | FIX BEFORE MERGE | BLOCK
Scope: <files and entry points reviewed>
Tools: `<command>` -> <result>
### Findings
### Hardening (no exploit shown)
### Not checked
.env or key files; never test against a live system.Key decisions in this skill: the severity of a Critical or High finding, whether an exploit path is real, a fix that changes auth, sessions, permissions or crypto, and a BLOCK verdict.
Before acting on one, get a second opinion: call the Agent tool with model: "opus" (subagent_type Plan, read-only). Give it the decision, each option in one line, the evidence (file:line, measurements, the diff) and the constraints. Ask for a pick, the main risk of that pick, and what would change its mind. Do not send secrets or .env contents.
Advisor: <decision> -> <pick> (<agreed | overruled because ...>).Spend the strong models on judgment and the cheap ones on volume. When this skill spawns subagents with the Agent tool, set model by role:
| Role | Model | Use for |
|---|---|---|
| Think | fable (Fable 5.2), or opus when limits are tight | Plan, decompose, pick an approach. One call, read-only (subagent_type: "Plan"). |
| Execute | sonnet (Sonnet 5.5) | Write and edit code, run checks, produce the deliverable. |
| Review | opus (Opus 5.5) | Check the finished work before reporting: correctness, security, money, data loss. |
| Swarm | haiku (Haiku 5.5) | Many small parallel jobs: search, read, extract, classify, per-file scans. |
mcp__ccd_session_mgmt__get_usage (load it with ToolSearch if deferred). Use fable only when every window has room: 5-hour limit under 70% used, "Weekly · all models" under 80%, and "Weekly · Fable" (if listed) under 80%. Otherwise use opus. If the tool is missing, or its status is unavailable or not_applicable (API key, Bedrock, Vertex), use opus. Say the pick in one line: Think: <model> (5h <n>%, weekly <n>%, Fable <n>%).Lessons from earlier runs live in two files: ~/.claude/skill-lessons/security-code-audit.md (any repo) and .claude/skill-lessons/security-code-audit.md at the repo root (this repo only).
- <YYYY-MM-DD>: <do or avoid X> because <Y>. (seen: 1). When a line already says the same thing, raise its seen count and date instead of adding one. Facts about this repo go in the repo file, everything else in the user file. Keep each file under 30 lines by merging or dropping stale lessons.seen: 3: if the ashish-claude-skills source repo is open, propose the edit to plugins/quality-gates/skills/security-code-audit/SKILL.md as a diff and wait for a yes, then delete the lesson once it lands; otherwise say Lesson ready to promote: <line> in the report.Learned: <the line written | nothing>.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub ashishyd/ashish-claude-skills --plugin quality-gates10 skills in this plugin
/claude-md-syncUse after changing business logic, domain rules, data models, APIs, architecture, commands, config or dependencies, before calling the work done, to keep CLAUDE.md true to the code. Also when the user says "update CLAUDE.md", "sync the docs" or "is CLAUDE.md still right"./design-auditUse when a UI component, page or stylesheet has just been built or changed and its visual quality needs checking, when the user asks whether a screen looks right, consistent or polished, or before shipping front-end work./login-and-accessUse when writing, changing or reviewing sign-in, sign-up, logout, password reset, magic links, OAuth or SSO, MFA, sessions, cookies, JWTs, refresh tokens, roles, permissions, admin areas, multi-tenant data or any route that must know who the caller is and what they may see./personal-dataUse when writing, changing or reviewing code that stores, reads, sends, logs, exports or deletes information about people (users, customers, clients, patients, children, employees), including new database columns or tables, migrations, forms, analytics or tracking events, error reporting, third-party APIs, AI prompts, data exports, account deletion, consent, cookie banners, retention jobs, or questions about GDPR, CCPA, LGPD, DPDP or other privacy laws./playwright-testsUse when writing, generating or fixing Playwright end-to-end tests, covering a user journey in a real browser, choosing locators, handling login state or test data, or when an e2e test is flaky, slow or times out./threat-modelUse when planning or designing a feature, service or integration that adds a new entry point, before a launch or a major release, when changing deploy, infrastructure, CI/CD, hosting or network config, when asked where an attacker could break in, for a threat model, attack surface review, launch security checklist, penetration test plan or scope, or when setting up security scanning.