From generate-crud-apis
Generate complete REST API modules from a Prisma schema with Supabase-style database operations. Creates full REST APIs with: select, include, pagination, sorting, ALL filter operators, insert, upsert, update, delete, RPC calls, and count options. Supports NestJS, NodeJS (Express/Fastify), and FastAPI frameworks. Supports both PostgreSQL and SQLite with appropriate filter adaptations. Trigger when: user wants to generate APIs from Prisma schema automatically, build Supabase-style REST APIs, or create full CRUD for all tables at once.
How this skill is triggered — by the user, by Claude, or both
Slash command
/generate-crud-apis:generate-crud-apisThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generates complete API modules for **ALL models** in a Prisma schema with Supabase-compatible database operations — in one shot.
references/controller-implementation.mdreferences/database-specifics.mdreferences/fastapi-implementation.mdreferences/field-types.mdreferences/filter-operators.mdreferences/nestjs-controller.mdreferences/nestjs-service.mdreferences/nodejs-implementation.mdreferences/service-implementation.mdreferences/sql-dev-endpoint.mdGenerates complete API modules for ALL models in a Prisma schema with Supabase-compatible database operations — in one shot.
Supported Frameworks:
Database Support:
mode: 'insensitive' support for case-insensitive searchmode argument neededThe skill auto-detects the framework from the project structure:
| Indicator | Framework |
|---|---|
package.json with @nestjs/core | NestJS |
package.json with express or fastify | NodeJS (Express/Fastify) |
requirements.txt or pyproject.toml with fastapi | FastAPI |
Specify explicitly in the prompt:
generate APIs for NestJSgenerate APIs for Expressgenerate APIs for FastAPIgenerate APIs for FastifyRead {project}/back/prisma/schema.prisma and parse ALL models:
Check project structure to determine framework:
package.json with NestJS/Express/Fastify dependenciesrequirements.txt or pyproject.toml with FastAPICheck existing API modules in the framework-appropriate location:
{project}/back/src/{project}/back/src/{project}/back/For every model in the schema, generate framework-specific files:
NestJS:
{project}/back/src/{modelName}/
├── {modelName}.controller.ts
├── {modelName}.service.ts
├── {modelName}.module.ts
└── dto/
├── create-{modelName}.dto.ts
└── query-{modelName}.dto.ts
NodeJS (Express/Fastify):
{project}/back/src/{modelName}/
├── {modelName}.router.js # or .ts
├── {modelName}.service.js # or .ts
└── {modelName}.validation.js # optional, for input validation
FastAPI:
{project}/back/
├── routers/
│ └── {modelName}.py
├── services/
│ └── {modelName}.py
└── schemas/
└── {modelName}.py
Update the framework-specific entry point:
app.module.tsapp.js or index.jsmain.pyThe service auto-detects PostgreSQL vs SQLite from DATABASE_URL:
// TypeScript (NestJS/NodeJS)
function getDbProvider(connectionString: string): 'postgresql' | 'sqlite' {
if (connectionString.startsWith('sqlite') || connectionString.includes('.db')) {
return 'sqlite';
}
return 'postgresql';
}
# Python (FastAPI)
def get_db_provider(connection_string: str) -> str:
if connection_string.startswith('sqlite') or '.db' in connection_string:
return 'sqlite'
return 'postgresql'
Full reference: See references/filter-operators.md
| Operator | PostgreSQL | SQLite | Description |
|---|---|---|---|
ilike_{field} | { contains: value, mode: 'insensitive' } | { contains: value } | Case-insensitive (PG only) |
textSearch_{field} | { contains: value, mode: 'insensitive' } | { contains: value } | Case-insensitive search |
rangegt/gte/lt/lte/adjacent | Supported | Not supported | Range operators (PG only) |
rpc | Supported | Throws error | Postgres function calls |
All frameworks return the same pagination format:
{
"data": [...],
"count": 100,
"page": 1,
"perPage": 20
}
Full implementation by framework:
references/nestjs-controller.mdreferences/nodejs-implementation.mdreferences/fastapi-implementation.mdFull implementation by framework:
references/nestjs-service.mdreferences/nodejs-implementation.mdreferences/fastapi-implementation.mdAlways use Number() for skip and take (or equivalent):
// TypeScript
const skip = offset !== undefined ? Number(offset) : (Number(page) - 1) * Number(perPage);
const take = limit !== undefined ? Number(limit) : Number(perPage);
# Python
skip = offset if offset is not None else (page - 1) * per_page
take = limit if limit is not None else per_page
| HTTP Code | Condition |
|---|---|
| 200 | Success |
| 201 | Created |
| 400 | Validation error, bad filter, RPC not supported |
| 404 | Record not found |
| 409 | Unique constraint violation |
| 500 | Server error |
P2025 error code: Record not found
GET /products?page=1&perPage=20
GET /products?sortBy=price,createdAt&order=asc,desc
GET /products?eq_category=electronics<_price=1000
GET /products?ilike_name=laptop
GET /products?in_category=electronics,books
GET /products?or=category.eq.electronics,price.lt.500
POST /products/rpc/my_function
Body: { "param1": "value1", "param2": 123 }
Details: See references/database-specifics.md
mode: 'insensitive' for case-insensitive searchDetails: See references/field-types.md
| Prisma Type | TypeScript/Python Type |
|---|---|
| String | string / str |
| Int | number / int |
| BigInt | bigint / int |
| Float | number / float |
| Decimal | string / str |
| Boolean | boolean / bool |
| DateTime | Date / datetime |
| Json | object / dict |
| Bytes | Buffer / bytes |
Uses @Controller, @Injectable, @Get, @Post, decorators with full DI system.
Reference: references/nestjs-controller.md, references/nestjs-service.md
Plain router pattern with express.Router() or Fastify's plugin system. Service layer is shared Prisma logic.
Reference: references/nodejs-implementation.md
Python with async/await, Pydantic for request/response validation, APIRouter for routing, Depends for DI.
Reference: references/fastapi-implementation.md
For development convenience, add a raw SQL execution endpoint controlled by MODE=dev.
NestJS Implementation: See references/sql-dev-endpoint.md
For NodeJS/FastAPI, implement similar endpoint with MODE=dev check.
Searches MemPalace before answering questions about past work, people, projects, or prior decisions. Returns verbatim stored content instead of guessing from model memory.
Guides Payload CMS config (payload.config.ts), collections, fields, hooks, access control, APIs. Debugs validation errors, security, relationships, queries, transactions, hook behavior.
Implements vector databases with Pinecone, Weaviate, Qdrant, Milvus, pgvector for semantic search, RAG, recommendations, and similarity systems. Optimizes embeddings, indexing, and hybrid search.
npx claudepluginhub auraworks/my-marketplace --plugin generate-crud-apis