~/.claude/skills/api-endpoint-generator/SKILL.mdAPI Endpoint Generator
Scaffolds REST or GraphQL endpoints with proper validation, error handling, and types based on your existing API patterns.
---
name: api-endpoint-generator
description: |
Scaffolds REST or GraphQL endpoints with validation, error handling, and types.
IMPORTANT: Activate this skill whenever the user asks to "create an endpoint",
"add an API route", "build an API", or "scaffold an endpoint".
This skill MUST be used for all API endpoint creation requests.
---
# API Endpoint Generator
Scaffolds complete API endpoints by reading your existing routes and matching their patterns for validation, error handling, response format, and middleware usage.
**Trigger:**
Say any of these to activate this skill:
- "create an endpoint"
- "add an API route"
- "build an API for [resource]"
- "Use skill: api endpoint generator"
**How It Works:**
1. Scan the project's API route directory to identify the framework (Next.js App Router, Express, Fastify, Hono, etc.)
2. Read 2-3 existing route files to learn the project's patterns for validation, error handling, and response formatting
3. Check for validation libraries (zod, joi, yup) and use the same one
4. Identify middleware patterns (auth checks, rate limiting, CORS)
5. Generate the route file with proper HTTP method handlers
6. Include input validation for request body, query params, and path params
7. Add typed response objects matching existing patterns
8. Include error handling that follows the project's error response format
**Guidelines:**
- Match the existing error response shape exactly (e.g., `{ error: string }` vs `{ message: string, code: number }`)
- Use the same validation library already in the project
- Include auth/middleware guards if other protected routes use them
- Never hardcode secrets or connection strings
- Add proper HTTP status codes (201 for creation, 204 for deletion, etc.)
**Works With:**
- Best with: Claude Code CLI, Cursor, Windsurf
- Also works: Any AI coding tool that reads SKILL.md or custom instructions
- Expects: A project with at least one existing API route to pattern-match
**Output Format:**
- Route handler file in the correct directory
- Request/response types
- Validation schema using the project's validation libraryScaffolds complete API endpoints by reading your existing routes and matching their patterns for validation, error handling, response format, and middleware usage.
Say any of these to activate this skill: - "create an endpoint" - "add an API route" - "build an API for [resource]" - "Use skill: api endpoint generator"
1. Scan the project's API route directory to identify the framework (Next.js App Router, Express, Fastify, Hono, etc.) 2. Read 2-3 existing route files to learn the project's patterns for validation, error handling, and response formatting 3. Check for validation libraries (zod, joi, yup) and use the same one 4. Identify middleware patterns (auth checks, rate limiting, CORS) 5. Generate the route file with proper HTTP method handlers 6. Include input validation for request body, query params, and path params 7. Add typed response objects matching existing patterns 8. Include error handling that follows the project's error response format
- Match the existing error response shape exactly (e.g.,
{ error: string }vs{ message: string, code: number }) - Use the same validation library already in the project
- Include auth/middleware guards if other protected routes use them
- Never hardcode secrets or connection strings
- Add proper HTTP status codes (201 for creation, 204 for deletion, etc.)
- Best with: Claude Code CLI, Cursor, Windsurf
- Also works: Any AI coding tool that reads SKILL.md or custom instructions
- Expects: A project with at least one existing API route to pattern-match
- Route handler file in the correct directory
- Request/response types
- Validation schema using the project's validation library