- Home
- Skills
- Frontend & Web Apps
- Next.js 15 Server Action Validator
More screenshots
Works with the AI Agents you already use
Next.js 15 Server Action Validator
Free 5-point audit for Next.js 15 Server Actions. Checks for swallowed redirects, raw error leaks, missing auth, and Zod validation gaps before they hit production.
Free
Next.js 15 Server Action Validator
Example session with this skill installed
Review this Server Action for production issues:
'use server'
import { prisma } from '@/lib/db'
import { redirect } from 'next/navigation'
export async function updateProfile(formData: FormData) {
try {
const name = formData.get('name')
await prisma.user.update({
where: { id: 'user_123' },
data: { name: String(name) }
})
redirect('/profile')
} catch (e) {
return { error: e.message }
}
}
- Read your context and instructions
- Compiled the next js 15
- Generated the document
Audit Summary
Passed 1/5 checks. This Server Action has critical security and functionality flaws that will fail in production.
| Check | Status | Why it matters |
|---|---|---|
| 1. Redirect Trap | ❌ Fail | redirect('/profile') is inside the try block. The catch block will swallow the redirect error. The user will never be redirected. |
| 2. Error Leakage | ❌ Fail | return { error: e.message } will leak your Prisma schema and database structure to the client. |
| 3. Validation | ❌ Fail | formData.get('name') is cast to string without Zod validation. A user could send an empty string or a 10MB payload. |
| 4. Auth Check | ❌ Fail | There is no auth() check. Anyone can call this action and update user_123. |
| 5. Cache Invalidation | ❌ Fail | Missing revalidatePath('/profile'). The UI will show stale data after the update. |
Corrected Code
'use server'
import { prisma } from '@/lib/db'
import { redirect, unstable_rethrow } from 'next/navigation'
import { auth } from '@/lib/auth'
import { z } from 'zod'
import { revalidatePath } from 'next/cache'
const schema = z.object({ name: z.string().min(1).max(50) })
export async function updateProfile(formData: FormData) {
// 4. Auth Check
const session = await auth()
if (!session?.user) throw new Error('Unauthorized')
try {
// 3. Validation
const parsed = schema.parse({ name: formData.get('name') })
await prisma.user.update({
where: { id: session.user.id },
data: { name: parsed.name }
})
// 5. Cache Invalidation
revalidatePath('/profile')
} catch (e: any) {
// 1. Do not swallow redirects/notFound
unstable_rethrow(e)
// 2. Safe error message
return { error: 'Failed to update profile. Please try again.' }
}
// Move redirect OUTSIDE the try/catch
redirect('/profile')
}
**Next steps**
This fixes the immediate bugs. If you need the full production-grade architecture (Prisma connection pool timeouts, retry logic, and proper error.tsx routing), check out my paid skill **Next.js 15 + Prisma Error Architect** on my profile.
error.tsx
PDF · document
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
About this skill
The Problem
Server Actions in Next.js 15 are public API endpoints. Generic AI writes them with a standard try/catch and return e.message. This works in a tutorial, but in production it leads to three disastrous bugs:
- Swallowed redirects —
redirect()throws a special error. If you catch it, the redirect fails silently. - Schema leaks — Returning
e.messageexposes your Prisma errors and internal logic to the user. - Security bypass — Not validating
FormDataor checking auth inside the action allows anyone to mutate your database.
What this skill does
This is a free validator. When you ask your agent to review a Server Action, it applies a strict 5-point audit:
- The Redirect Trap — Ensures
redirect()isn’t swallowed bytry/catch. - Error Sanitization — Prevents raw database errors from leaking to the client.
- Input Validation — Forces Zod (or similar) validation on raw
FormData. - Auth Verification — Ensures session checks happen inside the Action.
- Cache Invalidation — Checks for
revalidatePath()after mutations.
It outputs a Pass/Fail table and the corrected, production-ready code.
Why is this free?
Because this validator catches the surface-level mistakes.
If you want the deep, production-grade architecture for handling Prisma connection pool timeouts, exponential backoff retries, and complex RSC error boundaries, check out my paid skill on my profile: Next.js 15 + Prisma Error Architect.
Ideal for
- Developers moving from Pages Router to App Router
- Anyone building forms with Server Actions
- Teams doing code reviews
Known Limitations
- Only works with Next.js App Router Server Actions that start with
'use server'. It will not audit Pages Router, Route Handlers (route.ts), or Client Components. - Does not perform deep Prisma / database-layer analysis (connection pool timeouts, retry logic, transaction safety, etc.). Those are covered in the paid Error Architect skill.
- Relies on the code the user pastes. It cannot scan your full project or detect issues outside the provided function.
- Suggests Zod for validation, but does not install packages or modify your
package.json. - The soft CTA points to the paid skill for advanced error handling. This free version stays focused on the 5 most common surface-level mistakes.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scan
Security scan passed 12 days ago
- Free with an Agensi account
Permissions
File Scopes
This skill only reads the Server Action code the user pastes. It does not write files, run terminal commands, or access the network.text