api-generator
Generate CRUD API endpoints automatically. User doesn't see routes.Use when: features need backend logic.Triggers: internal use only.
When & Why to Use This Skill
The API Generator skill is a powerful developer tool designed to automate the creation of production-ready CRUD API endpoints. By transforming high-level requirements into functional code, it eliminates repetitive boilerplate tasks while ensuring best practices in backend architecture. It supports multiple frameworks including Next.js, FastAPI, and Hono, and automatically integrates essential features such as input validation, authentication middleware, and OpenAPI documentation to enhance developer productivity and code consistency.
Use Cases
- Rapid Prototyping: Quickly generate a full suite of RESTful endpoints for new features like 'Expense Tracking' or 'User Profiles' without manual routing.
- Standardizing Backend Logic: Automatically apply consistent authentication, error handling, and validation schemas across different API routes and frameworks.
- Automated Documentation: Maintain up-to-date OpenAPI specifications for all generated endpoints to ensure seamless integration with frontend teams and external services.
- Database Integration: Streamline the connection between high-level resource definitions and database operations (GET, POST, PUT, DELETE) using optimized templates.
| name | api-generator |
|---|---|
| description | | |
| Use when | features need backend logic. |
| Triggers | internal use only. |
API Generator
Create endpoints from requirements. User never writes routes.
Process
Identify resources
- "Manage expenses" → /api/expenses
- "User profile" → /api/users/me
Generate CRUD
- GET (list, single)
- POST (create)
- PUT/PATCH (update)
- DELETE (remove)
Add validation
- Input schemas
- Error handling
- Auth middleware
Generate OpenAPI
- Auto-document all endpoints
- For future integrations
Template-Specific
Next.js API Routes
// app/api/expenses/route.ts
export async function GET() {
const expenses = await db.expenses.findMany();
return Response.json(expenses);
}
export async function POST(req: Request) {
const data = await req.json();
const expense = await db.expenses.create({ data });
return Response.json(expense);
}
FastAPI
@router.get("/expenses")
async def list_expenses(db: Session = Depends(get_db)):
return db.query(Expense).all()
@router.post("/expenses")
async def create_expense(data: ExpenseCreate, db: Session = Depends(get_db)):
expense = Expense(**data.dict())
db.add(expense)
db.commit()
return expense
Hono
app.get('/expenses', async (c) => {
const expenses = await db.select().from(expensesTable);
return c.json(expenses);
});
app.post('/expenses', async (c) => {
const data = await c.req.json();
const [expense] = await db.insert(expensesTable).values(data).returning();
return c.json(expense);
});
Auto-Generated Features
| Feature | Implementation |
|---|---|
| Pagination | ?page=1&limit=20 |
| Filtering | ?category=food |
| Sorting | ?sort=amount&order=desc |
| Auth | Middleware checks token |
| Validation | Schema validates input |
User Experience
User: "Add expense tracking"
Internally:
- Generate /api/expenses endpoints
- Add validation schemas
- Connect to database
- Add auth middleware
- Generate OpenAPI spec
User sees: "✅ Expense API ready"