Skip to content

Security audit patterns for Next.js App Router, Server Actions, middleware, and API routes with severity ratings.

CCM score
52 of 100
skills.sh installs
381
GitHub stars
121
last updated
Jun 3, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers NEXT_PUBLIC_ env exposure, Server Action auth, API route auth, middleware matcher gaps, and security headers
  • Includes a severity table rating each issue from CRITICAL to LOW, plus quick grep and rg audit commands
  • Enforces checks that Server Actions verify sessions and validate input with Zod before database writes
  • Designed for reviewing Next.js apps that use next-auth or similar session handling

Install

$ npx -y skills add igorwarzocha/opencode-workflows --skill security-nextjs -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Security audit patterns for Next.js applications covering environment variable exposure, Server Actions, middleware auth, API routes, and App Router security.

Environment Variable Exposure

The NEXT_PUBLIC_ Footgun

NEXT_PUBLIC_* → Bundled into client JavaScript → Visible to everyone
No prefix     → Server-only → Safe for secrets

Audit steps:

  1. grep -r "NEXT_PUBLIC_" . -g "*.env*"
  2. For each var, ask: "Would I be OK if this was in view-source?"
  3. Common mistakes:
    • NEXT_PUBLIC_API_KEY (SHOULD be server-only)
    • NEXT_PUBLIC_DATABASE_URL (MUST NOT use)
    • NEXT_PUBLIC_STRIPE_SECRET_KEY (use STRIPE_SECRET_KEY)

Safe pattern:

// Server-only (API route, Server Component, Server Action)
const apiKey = process.env.API_KEY; // ✓ No NEXT_PUBLIC_

// Client-safe (truly public)
const publishableKey = process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY; // ✓ Publishable

next.config.js env Is Always Bundled

Values set in next.config.js under env are inlined into the client bundle, even without NEXT_PUBLIC_. Treat them as public.

Details

Repository
github.com/igorwarzocha/opencode-workflows
Categories
Security, Frontend & UI Code
First seen
Jun 3, 2026

Questions

What does the security-nextjs skill check for?

The security-nextjs skill audits Next.js App Router and Server Actions code for NEXT_PUBLIC_ environment variable exposure, missing auth in Server Actions and API routes, and middleware matcher gaps. It also flags dangerouslySetInnerHTML use and missing security headers in next.config.js.

How do I install the security-nextjs skill?

Run npx -y skills add igorwarzocha/opencode-workflows --skill security-nextjs -y in your project. Once installed, the agent can review your Next.js app for the security issues this skill covers.

Where does security-nextjs stand in the Security category?

It is one of the Security category skills on Claude Marketplaces, alongside azure-compliance, entra-agent-id, firebase-security-rules-auditor, security-audit and cloudflare-one. Its focus is narrower than those, covering Next.js-specific patterns such as NEXT_PUBLIC_ leaks and Server Action auth.

More from igorwarzocha/opencode-workflows

All 7

Similar to Security Nextjs

More Security