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.

skills.sh installs
332
GitHub stars
79
last updated
Aug 21, 2026

Install

$ npx -y skills add bobmatnyc/claude-mpm-skills --skill validated-handler --agent claude-code

Installs into .claude/skills of the current project.

Files

Next.js Validated Handler Pattern

Type-safe API route handler with automatic Zod validation for Next.js App Router.

When to Use This Skill

Use this skill when:

  • Building Next.js API routes (App Router)
  • Want automatic input validation with Zod
  • Need consistent error handling across API routes
  • Want to eliminate boilerplate validation code
  • Building type-safe APIs with TypeScript

The Problem

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

Details

Repository
github.com/bobmatnyc/claude-mpm-skills
Categories
Frontend Development, Backend & APIs
First seen
Jun 3, 2026

More from bobmatnyc/claude-mpm-skills

All 158
1tech-leads-club avatarperf-lighthousetech-leads-club/agent-skillsRun Lighthouse audits locally via CLI or Node API, parse and interpret reports, and set performance budgets. Use when measuring site performance, understanding 332skills.sh installs
2dirien avatarpulumi-typescriptdirien/claude-skillsScaffolds Pulumi TypeScript infrastructure-as-code projects, writes IaC code with proper resource configuration, manages Pulumi ESC environments for centralized329skills.sh installs
3wix avatarwds-docswix/skillsWix Design System component reference. Use when building UI with @wix/design-system, choosing components, or checking props and examples. Triggers on "what comp329skills.sh installs
4johnlindquist avatarraycast-extensionjohnlindquist/claudeBuild Raycast extensions with React and TypeScript. Use when the user asks to create a Raycast extension, command, or tool.328skills.sh installs
5jezweb avatarazure-authjezweb/claude-skillsMicrosoft Entra ID (Azure AD) authentication for React SPAs with MSAL.js and Cloudflare Workers JWT validation using jose library. Full-stack pattern with Autho327skills.sh installs
6thedivergentai avatargodot-compositionthedivergentai/gd-agentic-skillsExpert architectural standards for building scalable Godot GAMES (RPGs, Platformers, Shooters) using the Composition pattern (Entity-Component). Use when design326skills.sh installs