with one click
validation
Schema definition, parsing, and inference patterns using Zod.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Schema definition, parsing, and inference patterns using Zod.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Design-token and theming conventions for the Starter — semantic CSS variables in theme.css, Tailwind v4 @theme registration in globals.css, dark mode, and the Figma token-sync flow. Use when extracting repeated design values, adding/editing tokens, theming, or syncing tokens from Figma.
API service layer with ky/apiClient and Next.js API routes with Zod validation. Use when creating services, API endpoints, or HTTP calls.
Project file organization, naming conventions, and import patterns. Use when creating new files, organizing code, or deciding where to place modules.
Conventions when no auth provider is bundled. Use when adding authentication or guarding routes.
React component patterns — server vs client components, styling with cn(), props interfaces. Use when creating UI or shared components.
Use before writing or referencing any stack library — fetches version-accurate docs via the context7 MCP server so call signatures, hooks, and APIs match what is installed. Invoke on first usage of any non-none slot library, on any non-trivial Next.js API, or when uncertain whether an API is current.
| name | validation |
| description | Schema definition, parsing, and inference patterns using Zod. |
| paths | ["src/lib/validations/**"] |
Zod is the validation library for this project. Schemas live in
src/lib/validations/, exported through src/lib/validations/index.ts.
import { z } from 'zod'
export const userSchema = z.object({
id: z.string().uuid(),
email: z.string().email(),
name: z.string().min(1),
})
export type User = z.infer<typeof userSchema>
schema.parse(input) — throws ZodError on failure (use in API routes inside try/catch)schema.safeParse(input) — returns { success, data | error } (use in components)Common primitives live in src/lib/validations/primitives.ts. Compose
feature schemas from primitives to keep validation rules DRY:
import { email, password } from './primitives'
export const loginSchema = z.object({ email, password })
import { NextResponse } from 'next/server'
import { z } from 'zod'
const schema = z.object({ name: z.string().min(1) })
export async function POST(request: Request) {
try {
const body = await request.json()
const data = schema.parse(body)
return NextResponse.json({ data })
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json({ error: error.errors }, { status: 400 })
}
return NextResponse.json({ error: 'Internal error' }, { status: 500 })
}
}
When the forms slot uses React Hook Form, wire Zod via
@hookform/resolvers/zod. See the forms skill for the full pattern.
src/lib/validations/z.any() — prefer z.unknown() and narrow with refinement