用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/majiayu000/claude-skill-registry --skill api-integration命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | api-integration |
| slug | api-integration |
| version | 1.0.0 |
| category | core |
| description | Generate Next.js App Router API routes with Zod validation and TypeScript types |
| triggers | [{"pattern":"api|endpoint|route|fetch|request|rest|graphql","confidence":0.6,"examples":["create an API endpoint","build a REST API","I need API routes for CRUD","generate endpoint for users","create a fetch request handler","create endpoints to fetch data"]}] |
| mcp_dependencies | [{"server":"context7","required":false,"capabilities":["search"]},{"server":"exa","required":false,"capabilities":["search"]}] |
Automatically generate production-ready Next.js 15 App Router API routes with Zod validation, TypeScript types, and comprehensive error handling. This skill transforms natural language API requirements into fully functional RESTful endpoints following Next.js best practices.
This skill generates:
Activate this skill when the user requests:
Generates Next.js 15 App Router route handlers:
// app/api/posts/route.ts
import { NextRequest, NextResponse } from 'next/server'
import { postSchema } from '@/lib/validations/post'
import { handleAPIError } from '@/lib/api/errors'
export async function GET(request: NextRequest) {
try {
const { searchParams } = new URL(request.url)
const page = parseInt(searchParams.get('page') || '1')
const limit = parseInt(searchParams.get('limit') || '10')
// Fetch posts from database
const posts = await db.query.posts.findMany({
limit,
offset: (page - 1) * limit,
})
return NextResponse.json({ posts, page, limit })
} catch (error) {
return handleAPIError(error)
}
}
export async function () {
{
body = request.()
validated = postSchema.(body)
post = db.(posts).(validated).()
.(post, { : })
} (error) {
(error)
}
}
Automatically maps CRUD operations to HTTP methods:
| Operation | HTTP Method | Route Pattern | Description |
|---|---|---|---|
| List | GET | /api/posts | Get all resources |
| Get | GET | /api/posts/[id] | Get single resource |
| Create | POST | /api/posts | Create new resource |
| Update | PUT/PATCH | /api/posts/[id] | Update existing resource |
| Delete | DELETE | /api/posts/[id] | Delete resource |
Generates type-safe validation schemas:
// lib/validations/post.ts
import { z } from 'zod'
export const postSchema = z.object({
title: z.string().min(1).max(200),
content: z.string().min(1),
published: z.boolean().default(false),
authorId: z.string().uuid(),
tags: z.array(z.string()).optional(),
publishedAt: z.date().optional(),
})
export const createPostSchema = postSchema.omit({ id: true })
export const updatePostSchema = postSchema.partial()
export type Post = z.infer<typeof postSchema>
export type CreatePost = z.infer<typeof createPostSchema>
export type UpdatePost = z.< updatePostSchema>
Automatically infers Zod types from field names and context:
| Field Pattern | Zod Schema | Validation |
|---|---|---|
email | z.string().email() | Email format |
url, website | z.string().url() | URL format |
age, count | z.number().int().positive() | Positive integer |
price, amount | z.number().positive() | Positive number |
password | z.string().min(8) | Minimum length |
isActive, hasPermission | z.boolean() | Boolean |
tags, categories | z.array(z.string()) | String array |
createdAt, updatedAt | z.date() | Date object |
Generates comprehensive error handling:
// lib/api/errors.ts
import { NextResponse } from 'next/server'
import { ZodError } from 'zod'
export class APIError extends Error {
constructor(
message: string,
public statusCode: number = 500
) {
super(message)
this.name = 'APIError'
}
}
export class NotFoundError extends APIError {
constructor(resource: string) {
super(`${resource} not found`, 404)
this.name = 'NotFoundError'
}
}
export class ValidationError extends APIError {
constructor(message: string) {
super(message, 400)
. =
}
}
{
() {
(message, )
. =
}
}
() {
.(, error)
(error ) {
.(
{
: ,
: error.,
},
{ : }
)
}
(error ) {
.(
{
: error.,
},
{ : error. }
)
}
.(
{
: ,
},
{ : }
)
}
Generates consistent API response types:
// lib/api/types.ts
export interface APIResponse<T = unknown> {
data?: T
error?: string
message?: string
}
export interface PaginatedResponse<T> {
data: T[]
page: number
limit: number
total: number
hasMore: boolean
}
export interface APIErrorResponse {
error: string
issues?: Array<{
path: string[]
message: string
}>
}
When this skill is activated:
Parse API Requirements
Generate Route Structure
Create Validation Schemas
Add Error Handling
Generate Type Definitions
Write Output Files
app/api/{resource}/route.ts - List and Create operationsapp/api/{resource}/[id]/route.ts - Get, Update, Delete operationslib/validations/{resource}.ts - Zod schemaslib/api/errors.ts - Error handling utilitieslib/api/types.ts - Shared TypeScript typesUser Prompt: "Create a REST API for managing blog posts with CRUD operations"
Generated Output:
app/api/posts/route.ts - GET (list) and POST (create)app/api/posts/[id]/route.ts - GET (single), PUT (update), DELETElib/validations/post.ts - Zod schemasUser Prompt: "Create an API endpoint for users with email, name, age, and avatar URL"
Generated Output:
// Zod schema with field-specific validations
const userSchema = z.object({
email: z.string().email(),
name: z.string().min(1).max(100),
age: z.number().int().positive().max(150),
avatarUrl: z.string().url().optional(),
})
User Prompt: "Create protected API routes for managing user profiles with authentication"
Generated Output:
The skill uses proper status codes:
200 OK - Successful GET, PUT, PATCH201 Created - Successful POST204 No Content - Successful DELETE400 Bad Request - Validation errors401 Unauthorized - Authentication required403 Forbidden - Insufficient permissions404 Not Found - Resource not found500 Internal Server Error - Server errorsConsistent JSON responses:
// Success response
{
"data": { ... }
}
// Error response
{
"error": "Error message",
"issues": [ ... ] // For validation errors
}
// Paginated response
{
"data": [ ... ],
"page": 1,
"limit": 10,
"total": 50,
"hasMore": true
}
When Context7 MCP is available:
When Exa MCP is available:
app/api/
├── posts/
│ ├── route.ts # GET, POST
│ └── [id]/
│ └── route.ts # GET, PUT, DELETE
├── users/
│ ├── route.ts
│ └── [id]/
│ └── route.ts
└── auth/
└── callback/
└── route.ts
.parse() for strict validation (throws on error).safeParse() for custom error handlingz.inferSkill Version: 1.0.0 Last Updated: 2026-01-04 Maintainer: Turbocat Agent System