
Wraps Next.js App Router API routes with automatic Zod validation so you stop writing the same 30 lines of query parsing and error handling in every endpoint. You define a Zod schema, specify if it's validating query params or body, and get back fully typed input with consistent 400 responses when validation fails. Especially useful if you're building pagination across multiple routes since you can share schemas like paginationInputSchema and eliminate the manual coercion and range checking. The pattern shines when you have dozens of routes and want uniform error formats without boilerplate.
$ npx -y skills add bobmatnyc/claude-mpm-skills --skill validated-handler --agent claude-codeInstalls into .claude/skills of the current project.
Type-safe API route handler with automatic Zod validation for Next.js App Router.
Use this skill when:
Without a validated handler, every API route has repetitive validation code:
// ❌ REPETITIVE - Every route looks like this
export async function GET(request: NextRequest) {
try {
// 1. Parse query params
const { searchParams } = new URL(request.url);
const rawPage = searchParams.get('page');
const rawLimit = searchParams.get('limit');
// 2. Validate each param manually
if (!rawPage || isNaN(Number(rawPage))) {
return NextResponse.json(
{ error: 'Invalid page parameter' },
{ status: 400 }
);
}
if (!rawLimit || isNaN(Number(rawLimit))) {
return NextResponse.json(
{ error: 'Invalid limit parameter' },
{ status: 400 }
);
}
Sponsors