
Validated Handler
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-codeInstalls 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- Bad Example Skill329
- Emergency Release Workflow328
- Digitalocean Teams327
- Vector Search Workflows324
- Vercel Storage Data324
- Example Framework Skill323
- Vercel Teams Billing320
- Spring Boot319
- Rust Desktop Applications263
- Api Security Review257
- Anthropic Sdk254
- Testing Anti Patterns226
- Root Cause Tracing216
- Mcp206
- Tauri Event System203
- Condition Based Waiting199
- Mcp Builder188
- Writing Plans187
- Dispatching Parallel Agents185
- Requesting Code Review182
- Webapp Testing Patterns181
- Langchain Framework165
- Django Framework159
- React State Machines158