skills/tier1-foundation/api-endpoint-builder/SKILL.md
Generate production-ready API endpoints from natural language descriptions. Supports Next.js App Router, tRPC, and Express. Includes authentication, validation, error handling, and best practices. Use when building REST or tRPC APIs.
npx skillsauth add abcnuts/manus-skills api-endpoint-builderInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate production-ready API endpoints from natural language descriptions using AI.
This skill transforms natural language API specifications into complete, type-safe endpoints with:
python3 scripts/generate_endpoints.py "CRUD endpoints for blog posts"
python3 scripts/generate_endpoints.py "User management API" --framework trpc
python3 scripts/generate_endpoints.py "Product catalog endpoints" --framework express
Write a natural language description of the endpoints you need:
Simple:
"CRUD endpoints for blog posts"
Detailed:
"User management API with:
- List all users (paginated)
- Get user by ID
- Create new user
- Update user profile
- Delete user
- Get user's posts"
Specific Requirements:
"E-commerce product API with:
- List products with filtering (category, price range)
- Search products
- Get product details with reviews
- Add product to cart
- Update cart quantity
- Checkout"
Run the generator:
python3 scripts/generate_endpoints.py "<your description>" [options]
Options:
--framework nextjs - Next.js App Router (default)--framework trpc - tRPC router--framework express - Express.js router--auth - Include authentication (default: true)--no-auth - Exclude authentication--validation - Include Zod validation (default: true)--no-validation - Exclude validation--output-dir <path> - Output directory (default: current)The generator creates files with clear structure:
Next.js:
app/api/posts/route.ts # List & create
app/api/posts/[id]/route.ts # Get, update, delete
tRPC:
server/api/routers/posts.ts # Router with all procedures
Express:
routes/posts.ts # Router with all routes
Description:
"CRUD endpoints for blog posts with title, content, and status"
Command:
python3 scripts/generate_endpoints.py "CRUD endpoints for blog posts" --output-dir api/
Generated (excerpt):
// app/api/posts/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { z } from 'zod';
const createPostSchema = z.object({
title: z.string().min(1).max(255),
content: z.string().min(1),
status: z.enum(['draft', 'published']).default('draft'),
});
export async function GET(request: NextRequest) {
// List posts with pagination
}
export async function POST(request: NextRequest) {
// Create new post with validation and auth
}
Description:
"User management API with list, get, create, update, delete"
Command:
python3 scripts/generate_endpoints.py "User management API" --framework trpc
Generated (excerpt):
export const userRouter = createTRPCRouter({
getAll: publicProcedure
.input(z.object({ limit: z.number().default(10) }))
.query(async ({ ctx, input }) => {
// List users
}),
create: protectedProcedure
.input(z.object({ email: z.string().email(), name: z.string() }))
.mutation(async ({ ctx, input }) => {
// Create user
}),
});
Description:
"Product catalog API with search, filtering, and cart management"
Command:
python3 scripts/generate_endpoints.py "Product catalog API" --framework express --output-dir routes/
Best for: Full-stack Next.js applications
Pros:
Cons:
Example:
// app/api/posts/route.ts
export async function GET(request: NextRequest) {
const posts = await db.post.findMany();
return NextResponse.json(posts);
}
Best for: Type-safe full-stack TypeScript apps
Pros:
Cons:
Example:
export const postRouter = createTRPCRouter({
getAll: publicProcedure.query(async ({ ctx }) => {
return await ctx.db.post.findMany();
}),
});
Best for: Standalone Node.js APIs
Pros:
Cons:
Example:
router.get('/posts', async (req, res) => {
const posts = await db.post.findMany();
res.json(posts);
});
Create, Read, Update, Delete for any resource:
"CRUD endpoints for [resource]"
Generates:
GET /api/[resource] - List allPOST /api/[resource] - CreateGET /api/[resource]/[id] - Get onePUT /api/[resource]/[id] - UpdateDELETE /api/[resource]/[id] - DeleteAutomatically includes pagination for list endpoints:
GET /api/posts?limit=10&page=1
Protected endpoints check for authenticated user:
const session = await getServerSession();
if (!session?.user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
Checks if user owns the resource:
if (post.userId !== session.user.id) {
return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
}
All inputs validated with Zod:
const schema = z.object({
title: z.string().min(1).max(255),
content: z.string(),
});
const data = schema.parse(body);
Consistent error responses:
try {
// Logic
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Validation failed', details: error.errors },
{ status: 400 }
);
}
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
);
}
Use templates/trpc_router.ts for tRPC patterns:
Use templates/nextjs_route.ts for Next.js patterns:
The generator follows these best practices automatically:
GET for readingPOST for creatingPUT/PATCH for updatingDELETE for deleting200 - Success201 - Created400 - Bad request401 - Unauthorized403 - Forbidden404 - Not found500 - Server errorAll inputs validated with Zod schemas before processing.
Protected endpoints check for authenticated users.
Ownership checks before modifying resources.
Consistent error format with proper status codes.
Full type safety throughout.
List endpoints include pagination by default.
Modify Zod schemas in generated code:
// Generated
title: z.string().min(1).max(255)
// Customize
title: z.string().min(5).max(100)
Insert business logic in generated endpoints:
export async function POST(request: NextRequest) {
// Generated validation
const data = schema.parse(body);
// Add custom logic
if (await isDuplicate(data.title)) {
return NextResponse.json(
{ error: 'Title already exists' },
{ status: 409 }
);
}
// Generated creation
const post = await db.post.create({ data });
}
Replace Prisma calls with your ORM:
// Generated (Prisma)
const posts = await db.post.findMany();
// Replace with Supabase
const { data: posts } = await supabase.from('posts').select('*');
// Or raw SQL
const posts = await sql`SELECT * FROM posts`;
Solution: Check imports and adjust for your project structure:
// Generated
import { db } from '~/server/db';
// Adjust to your project
import { db } from '@/lib/db';
Solution: Ensure auth setup matches your project:
// For NextAuth
import { getServerSession } from 'next-auth';
// For Supabase
import { createServerClient } from '@supabase/ssr';
Solution: Check Zod error handling:
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Validation failed', details: error.errors },
{ status: 400 }
);
}
Generate endpoints for multiple resources:
python3 scripts/generate_endpoints.py "CRUD for posts" --output-dir api/posts/
python3 scripts/generate_endpoints.py "CRUD for comments" --output-dir api/comments/
python3 scripts/generate_endpoints.py "CRUD for users" --output-dir api/users/
Describe relationships in the specification:
"Blog API with:
- Posts with author and comments
- Comments belong to posts and users
- Users can like posts
- Tags for posts (many-to-many)"
Add custom middleware to generated endpoints:
// Add rate limiting
import { rateLimit } from '@/lib/rate-limit';
export async function POST(request: NextRequest) {
if (!rateLimit(request.ip)) {
return NextResponse.json({ error: 'Too many requests' }, { status: 429 });
}
// Generated code
}
references/api_patterns.md - API design patterns and best practicestemplates/trpc_router.ts - tRPC router templatetemplates/nextjs_route.ts - Next.js route template✅ Endpoints generate without errors
✅ Code compiles in your project
✅ Validation works correctly
✅ Authentication checks pass
✅ Error handling is consistent
✅ Endpoints follow REST principles
✅ TypeScript types are correct
After generating your endpoints:
tools
Generate comprehensive demonstrations showing how to access projects and work across different environments (Manus terminals, personal computers, team collaboration). Use when users ask "how do I access this from another terminal/computer", "how do I share this with my team", "how do I get this on my Mac", or need clarification on Manus persistence vs GitHub usage.
development
Use when you have a spec or requirements for a multi-step task, before touching code
data-ai
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
development
Use when implementing any feature or bugfix, before writing implementation code