Next.js Audit
Audit like a Next.js domain expert, not a linter. The framework has
sharp edges that compile fine and pass tests: server actions are
public HTTP endpoints, RSC props serialize into the HTML, caching
defaults changed between majors, layouts don't re-run on soft
navigation. This skill hunts those — plus drift from the project's
own documented conventions.
Inputs and modes
| Invocation |
Behavior |
/nextjs-audit |
Diff mode: audit changed files (branch vs merge base, or uncommitted diff). Single-threaded. |
/nextjs-audit <PR#> |
Diff mode against a GitHub PR (fetch full files from head ref, never judge hunks alone). |
/nextjs-audit --full |
Whole-repo sweep. Parallel category subagents (references/scaling.md). |
--fix |
After the report, apply verified fixes (references/fix-mode.md). Never without the flag. |
--comment |
Post blocker/should-fix findings as inline GitHub PR comments (references/delivery.md). Never without the flag. |
Workflow
- Discovery (
references/discovery.md). Detect Next.js version
and router from package.json + tree. Pages Router → bail with a
clear message. Find the project's convention guide
(NEXTJS_GUIDE.md / AGENTS.md / CLAUDE.md / CONTRIBUTING.md /
docs/) and extract auditable invariants. No guide → best-practices
only + infer dominant codebase patterns.
- Scope. Diff mode: list changed files (read-only git; three-dot
diff vs merge base). Full mode: map
src//app/ surface.
- Triage. Skip files that can't carry a finding (formatting-only,
generated, lockfiles). When in doubt, audit it.
- Category passes. Each category has its own rule catalog —
load only what the scope needs:
references/rules-boundary.md — server/client boundary, secret
and data leakage
references/rules-auth.md — actions, routes, webhooks, crons,
IDOR, middleware traps
references/rules-caching.md — revalidation, cache poisoning,
transactions, races
references/rules-effects.md — the you-might-not-need-an-effect
catalog
references/rules-conventions.md — conformance to the discovered
guide
In full mode, these run as parallel subagents (references/scaling.md).
- Verification gate (
references/verification-gate.md). Every
candidate finding gets a disproof attempt — the guard may live in a
layout, middleware, the data layer, or a sibling. Nothing emits
without file:line evidence and a nameable failure scenario.
- Report (
references/delivery.md). Three tiers — Blocker /
Should-fix / Nit. Risk is reported at true severity even when the
project's guide blesses the pattern; the conflict is noted inline.
--fix if requested (references/fix-mode.md). Bar: tsc +
lint + build green per batch; auth-semantic fixes get a re-read
pass. Never commit or push.
Core stance
- Evidence first. Every finding cites file:line and survives an
active disproof attempt. A false positive in an audit poisons trust
in the whole report.
- The guide is input, not law. Conventions from the project guide
are enforced (mostly as nits/should-fix), but a genuinely risky
pattern the guide endorses is still reported at true severity, with
the conflict named — "the guide documents this; the convention
itself should change."
- Severity = real-world consequence. Blocker: security, data
loss, cross-user leakage, broken production behavior. Should-fix:
correctness and caching bugs with bounded blast radius, auth
hygiene. Nit: convention drift with no runtime consequence.
- Fewer, stronger findings. Merge same-root-cause findings. A
clean category is reported as checked-clean, not padded.
- Read-only by default. Gathering context never mutates the repo.
Fixes only via
--fix; GitHub comments only via --comment.
Reference loading map
- Always:
references/discovery.md, references/verification-gate.md.
- Per category in scope: the matching
references/rules-*.md.
references/scaling.md — only for --full.
references/fix-mode.md — only for --fix.
references/delivery.md — before writing the report; the GitHub
section only for --comment or PR targets.
Output contract
## Verdict
One human line: overall shape of the audit. Worst finding is the
headline.
## Target
Mode (diff/full), Next.js version, router, guide found (path or
"none — best-practices mode").
## Findings
### Blockers
1. `file:line` — title
Issue: trigger → path → wrong outcome
Evidence: quoted code / config
Fix: concrete change
[Guide conflict: guide section X documents this pattern — the
convention should change.] ← only when applicable
### Should fix
...
### Nits (non-blocking)
...
## Checked clean
- category: what was checked and why it passed
Rules:
- No findings → "No findings." + Checked clean. Never pad.
- Never leak internal labels (Confirmed/Plausible, rule IDs) into the
report.
- Don't duplicate what tsc/ESLint already enforces in this repo.
- Don't report pre-existing issues in diff mode unless the diff
touched or worsened them (full mode reports everything in scope).
- Don't invent conventions — cite the guide section or the dominant
codebase pattern you verified.
Non-goals
- Not a generic code review (that's big-review) — this audits
framework invariants and architecture, and goes deep on them.
- No style bible, no praise, no PR summary.
- Never mutate files, commit, push, or post comments without the
explicit flag.
1---2name: nextjs-audit3description: Evidence-first Next.js (App Router, 14+) audit for any repo. Use for "nextjs audit", "audit this app", "framework audit", "RSC boundary check", "server action audit", "next audit", auditing server/client boundaries, auth on actions/routes, caching/revalidation correctness, useEffect anti-patterns, and convention conformance against the project's own guide.4---56# Next.js Audit78Audit like a Next.js domain expert, not a linter. The framework has9sharp edges that compile fine and pass tests: server actions are10public HTTP endpoints, RSC props serialize into the HTML, caching11defaults changed between majors, layouts don't re-run on soft12navigation. This skill hunts those — plus drift from the project's13own documented conventions.1415## Inputs and modes1617| Invocation | Behavior |18|---|---|19| `/nextjs-audit` | Diff mode: audit changed files (branch vs merge base, or uncommitted diff). Single-threaded. |20| `/nextjs-audit <PR#>` | Diff mode against a GitHub PR (fetch full files from head ref, never judge hunks alone). |21| `/nextjs-audit --full` | Whole-repo sweep. Parallel category subagents (`references/scaling.md`). |22| `--fix` | After the report, apply verified fixes (`references/fix-mode.md`). Never without the flag. |23| `--comment` | Post blocker/should-fix findings as inline GitHub PR comments (`references/delivery.md`). Never without the flag. |2425## Workflow26271. **Discovery** (`references/discovery.md`). Detect Next.js version28 and router from `package.json` + tree. Pages Router → bail with a29 clear message. Find the project's convention guide30 (NEXTJS_GUIDE.md / AGENTS.md / CLAUDE.md / CONTRIBUTING.md /31 docs/) and extract auditable invariants. No guide → best-practices32 only + infer dominant codebase patterns.332. **Scope.** Diff mode: list changed files (read-only git; three-dot34 diff vs merge base). Full mode: map `src/`/`app/` surface.353. **Triage.** Skip files that can't carry a finding (formatting-only,36 generated, lockfiles). When in doubt, audit it.374. **Category passes.** Each category has its own rule catalog —38 load only what the scope needs:39 - `references/rules-boundary.md` — server/client boundary, secret40 and data leakage41 - `references/rules-auth.md` — actions, routes, webhooks, crons,42 IDOR, middleware traps43 - `references/rules-caching.md` — revalidation, cache poisoning,44 transactions, races45 - `references/rules-effects.md` — the you-might-not-need-an-effect46 catalog47 - `references/rules-conventions.md` — conformance to the discovered48 guide49 In full mode, these run as parallel subagents (`references/scaling.md`).505. **Verification gate** (`references/verification-gate.md`). Every51 candidate finding gets a disproof attempt — the guard may live in a52 layout, middleware, the data layer, or a sibling. Nothing emits53 without file:line evidence and a nameable failure scenario.546. **Report** (`references/delivery.md`). Three tiers — Blocker /55 Should-fix / Nit. Risk is reported at true severity even when the56 project's guide blesses the pattern; the conflict is noted inline.577. **`--fix`** if requested (`references/fix-mode.md`). Bar: tsc +58 lint + build green per batch; auth-semantic fixes get a re-read59 pass. Never commit or push.6061## Core stance6263- **Evidence first.** Every finding cites file:line and survives an64 active disproof attempt. A false positive in an audit poisons trust65 in the whole report.66- **The guide is input, not law.** Conventions from the project guide67 are enforced (mostly as nits/should-fix), but a genuinely risky68 pattern the guide endorses is still reported at true severity, with69 the conflict named — "the guide documents this; the convention70 itself should change."71- **Severity = real-world consequence.** Blocker: security, data72 loss, cross-user leakage, broken production behavior. Should-fix:73 correctness and caching bugs with bounded blast radius, auth74 hygiene. Nit: convention drift with no runtime consequence.75- **Fewer, stronger findings.** Merge same-root-cause findings. A76 clean category is reported as checked-clean, not padded.77- **Read-only by default.** Gathering context never mutates the repo.78 Fixes only via `--fix`; GitHub comments only via `--comment`.7980## Reference loading map8182- **Always**: `references/discovery.md`, `references/verification-gate.md`.83- Per category in scope: the matching `references/rules-*.md`.84- `references/scaling.md` — only for `--full`.85- `references/fix-mode.md` — only for `--fix`.86- `references/delivery.md` — before writing the report; the GitHub87 section only for `--comment` or PR targets.8889## Output contract9091```92## Verdict93One human line: overall shape of the audit. Worst finding is the94headline.9596## Target97Mode (diff/full), Next.js version, router, guide found (path or98"none — best-practices mode").99100## Findings101102### Blockers1031. `file:line` — title104 Issue: trigger → path → wrong outcome105 Evidence: quoted code / config106 Fix: concrete change107 [Guide conflict: guide section X documents this pattern — the108 convention should change.] ← only when applicable109110### Should fix111...112113### Nits (non-blocking)114...115116## Checked clean117- category: what was checked and why it passed118```119120Rules:121- No findings → "No findings." + Checked clean. Never pad.122- Never leak internal labels (Confirmed/Plausible, rule IDs) into the123 report.124- Don't duplicate what tsc/ESLint already enforces in this repo.125- Don't report pre-existing issues in diff mode unless the diff126 touched or worsened them (full mode reports everything in scope).127- Don't invent conventions — cite the guide section or the dominant128 codebase pattern you verified.129130## Non-goals131132- Not a generic code review (that's big-review) — this audits133 framework invariants and architecture, and goes deep on them.134- No style bible, no praise, no PR summary.135- Never mutate files, commit, push, or post comments without the136 explicit flag.