Next.js API Route Validator skill for Claude and Codex
Produces a drop-in validation middleware for one Next.js API route using Joi, Zod, Yup, Superstruct, or plain checks, so bad requests get a consistent 400…
Install it once and Claude or Codex runs it for you. When your request matches, your AI loads the skill, asks for anything it is missing, and works through the template itself. Prefer to fill it in by hand? See the full prompt template.
Download the skill (.zip) · View SKILL.md
When it is used
Use when a Next.js API route needs a reusable request validation middleware with Joi, Zod, Yup, Superstruct, or hand-written checks that answers 400 consistently. Do not use for generating the whole route handler or validating responses. Related topics: coding, next.js.
What it will ask you for
- HTTP method (choose one: GET, POST, PUT, DELETE, PATCH)
- Route path (free text, e.g. "/api/example")
- Validation library (choose one: Joi, Zod, Yup, Superstruct, No Library)
- Schema definition (longer free text)
- Required fields (choose any: name, email, password, id)
- Error response format (choose one: JSON, Plain Text)
How it works
- Pick the request part to validate from the method: body for POST, PUT, and PATCH, query for GET and DELETE.
- Translate the schema into the chosen library with the selected fields required, or into explicit checks that collect every failure when no library is used.
- Write the wrapper that parses, answers 400 in the chosen format with one entry per failed field, and attaches the parsed value as req.validated.
- Add the usage example showing a handler wrapped with the middleware and the default export, then output the js file.
What you get
One code block tagged js: imports, the schema, the validation middleware (handler in, handler out), a short usage example, and a default export.
What it watches out for
- Validating req.body on a GET route, where the body is always empty and the real input lives in req.query.
- Returning only the first validation error, so the client fixes fields one round trip at a time.
- Passing the raw, unparsed body to the handler after validation, which loses the library's coercions and defaults.
How to install
Claude.ai and the Claude desktop app
- Download the skill .zip.
- Open Settings, then Capabilities, and find Skills.
- Choose Upload skill and select the .zip.
- Ask Claude for help with the task. It loads the skill when your request matches.
Claude Code
- Download the skill .zip.
- Unzip it into ~/.claude/skills/ (or .claude/skills/ inside a project).
- Start a new session. Claude Code loads the skill when your request matches.
Codex
- Download the skill .zip.
- Unzip it into ~/.agents/skills/ (or .agents/skills/ inside a project).
- Codex picks it up on its own. Type $ and the skill name to use it, or just ask for the task.
Cursor
- Download the Cursor rule (.mdc).
- Save it in .cursor/rules/ inside your project.
- Cursor's agent applies the rule when your request matches its description.
AGENTS.md (Codex, Cursor, and other coding agents)
- Copy the AGENTS.md section.
- Paste it into AGENTS.md at the root of your repository, creating the file if needed.
- Coding agents that read AGENTS.md follow it when your request fits.