Automated summary
Generates a new Next.js API route in the App Router with TypeScript types, Zod input validation, error handling, and optional rate limiting or authentication.
Strengths
- Provides a standardized template with proper error handling and validation.
- Supports integration with Arcjet for rate limiting and Clerk for authentication.
- Generates clean TypeScript code with typed request validation.
- Reduces boilerplate and ensures consistent API route structure.
Limitations
- Only supports Next.js App Router, not Pages Router.
- Assumes specific libraries (Zod, Arcjet, Clerk) are already configured in the project.
- Does not cover advanced scenarios like file uploads or streaming responses.
When you need to quickly scaffold a new API endpoint in a Next.js App Router project with validation and security best practices.
When building routes in the Pages Router, or if you prefer a different validation library or authentication provider.
Security analysis
SafeThe skill provides a template for creating Next.js API routes with best practices like input validation, error handling, and optional rate limiting/authentication. It does not include any destructive, exfiltrating, or obfuscated instructions, and uses standard development patterns.
No concerns found
How this analysis is madeExamples
Add a new public API route called 'feedback' that accepts POST requests. Include Zod validation for an email and message field, and add Arcjet rate limiting.Create a protected API route for 'profile/update' that uses Clerk for authentication. It should accept a PUT method and validate a name field using Zod.Add API Route
Create a new Next.js API route with proper patterns.
Description
Creates a new API route in the Next.js App Router with:
- TypeScript types
- Zod input validation
- Error handling
- Rate limiting setup (optional)
- Authentication check (optional)
Instructions
- Create a new folder in
app/api/[route-name]/ - Create
route.tswith the appropriate HTTP handlers - Add Zod schema for request validation
- Include proper error handling with status codes
- Add rate limiting using Arcjet if public-facing
- Add Clerk authentication if the endpoint is protected
Parameters
route_name- The URL path for the route (e.g., "webhooks", "notifications")methods- HTTP methods to support (GET, POST, PUT, DELETE)is_public- Whether the route is public or requires authneeds_rate_limit- Whether to add Arcjet rate limiting
Template
import { NextRequest, NextResponse } from 'next/server';
import { z } from 'zod';
// Input validation schema
const RequestSchema = z.object({
// Define your schema here
});
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const validated = RequestSchema.parse(body);
// Your logic here
return NextResponse.json({ success: true });
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Validation failed', details: error.errors },
{ status: 400 }
);
}
console.error('API Error:', error);
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
);
}
}
Examples
Public endpoint with rate limiting
import { arcjet } from '@/lib/arcjet';
export async function POST(request: NextRequest) {
const decision = await arcjet.protect(request);
if (decision.isDenied()) {
return NextResponse.json({ error: 'Rate limited' }, { status: 429 });
}
// ... rest of handler
}
Protected endpoint
import { auth } from '@clerk/nextjs/server';
export async function POST(request: NextRequest) {
const { userId } = await auth();
if (!userId) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// ... rest of handler
}
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/add-api-route-mm8o52g9/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/add-api-route-mm8o52g9' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/add-api-route-mm8o52g9/download' --output '.skill-downloads/add-api-route-mm8o52g9/SKILL.md.part' && mv '.skill-downloads/add-api-route-mm8o52g9/SKILL.md.part' '.skill-downloads/add-api-route-mm8o52g9/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.
Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/add-api-route-mm8o52g9/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.