add-api-route
Create Next.js API route with validation and error handling
npx skills add majiayu000/claude-skill-registry --skill add-api-route --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Add API Route: $ARGUMENTS Create a Next.js API route with proper validation, error handling, and types. ## Process ### 1. Determine Route Structure Parse arguments to determine: - Route path (e.g., `users`, `posts/[id]`) - HTTP methods (GET, POST, PUT, DELETE) - Dynamic segments if any ### 2. Create Route File **App Router (Next.js 13+):** ``` app/api/[route]/route.ts ``` **Pages Router:** ``` pages/api/[route].ts ``` ### 3. Generate Route Handler **App Router template:** ```typescript import { NextRequest, NextResponse } from 'next/server'; // Types interface RequestBody { // define expected body shape } interface ResponseData { // define response shape } // GET handler export async function GET(request: NextRequest) { try { // Implementation return NextResponse.json({ data: [] }); } catch (error) { console.error('GET error:', error); return NextResponse.json( { error: 'Internal server error' }, { status: 500 } ); } } // POST handler export async function POST(request: NextRequest) { try { const body: RequestBody = await request.json(); // Validate if (!body.requiredField) { return NextResponse.json( { error: 'Missing required field' }, { status: 400 } ); } // Implementation ret
- Process
- 1. Determine Route Structure
- 2. Create Route File
- 3. Generate Route Handler
- 4. Add Type Definitions
- 5. Create Tests
- 6. Validate
- Patterns
npm run build npm test
What does the add-api-route skill do?
Create Next.js API route with validation and error handling
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill add-api-route --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
