nestjs-drizzle-crud-generator
giuseppe-trisciuoglio/developer-kit
Generate complete NestJS CRUD modules with Drizzle ORM, Zod validation, and tests.
What is nestjs-drizzle-crud-generator?
Automatically scaffolds full CRUD feature modules for NestJS applications using Drizzle ORM. Creates controllers, services, Zod-validated DTOs, database schemas, and Jest unit tests following monorepo patterns. Use when building new database-backed entities or features that need complete CRUD endpoints.
- Generates NestJS feature modules with controllers, services, and schemas
- Creates Zod-validated DTOs for Create/Update/Query operations
- Builds Drizzle ORM service methods with pagination and filtering
- Generates Jest unit tests with mocked database
- Produces soft-delete enabled CRUD endpoints (POST, GET, PATCH, DELETE)
How to install nestjs-drizzle-crud-generator
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill nestjs-drizzle-crud-generator- NestJS project with Drizzle ORM configured
- Python installed for running the generator script
- Required packages: @nestjs/common, @nestjs/core, drizzle-orm, drizzle-zod, zod, nestjs-zod
- DatabaseModule already set up in your application
How to use nestjs-drizzle-crud-generator
- 1.Define your entity name and field list with types (string, email, number, boolean, text, etc.)
- 2.Run the generator: python scripts/generate_crud.py --feature <name> --fields '<json>' --output <path>
- 3.Verify generated files exist in libs/server/<feature-name>/src/lib/
- 4.Run TypeScript compilation: npx tsc --noEmit to check for type errors
- 5.Execute unit tests: npm test -- --testPathPattern=<feature-name>
- 6.Integrate the module into your app.module.ts using forRootAsync pattern
- 7.Customize service methods and add business logic as needed
Use cases
- Generate a user management module with authentication fields and validation
- Create a product catalog CRUD with pricing, inventory, and description fields
- Build an order processing module with status tracking and timestamps
- Generate a blog post module with title, content, and publication metadata
- Scaffold a settings/configuration entity with type-safe updates
- NestJS backend developers
- Full-stack developers building monorepo applications
- Teams using Drizzle ORM for type-safe database access
- Developers who want rapid CRUD scaffolding with testing
nestjs-drizzle-crud-generator FAQ
POST (create), GET (read with pagination), PATCH (update), and DELETE (soft delete via deletedAt timestamp). Hard deletes require manual implementation.
No. Generated endpoints have no auth guards. You must add authentication/authorization based on your security requirements.
Yes. After generation, modify services for business logic, adjust Zod validation rules in DTOs, and add guards/decorators to controllers.
String, email, number, boolean, text, and others defined in references/field-types.md. Check the documentation for the complete list.
Yes. The generator creates Drizzle schemas, but you must create and run migrations separately for your database.
Full instructions (SKILL.md)
Source of truth, from giuseppe-trisciuoglio/developer-kit.
name: nestjs-drizzle-crud-generator description: Generates complete CRUD modules for NestJS applications with Drizzle ORM. Use when building server-side features in NestJS that require database operations, including creating new entities with full CRUD endpoints, services with Drizzle queries, Zod-validated DTOs, and unit tests. Triggered by requests like "generate a user module", "create a product CRUD", "add a new entity with endpoints", or when setting up database-backed features in NestJS. allowed-tools: Read, Write, Edit, Glob, Grep, Bash
NestJS Drizzle CRUD Generator
Overview
Automatically generates complete CRUD modules for NestJS applications using Drizzle ORM. Creates all necessary files following the zaccheroni-monorepo patterns: feature modules, controllers, services, Zod-validated DTOs, Drizzle schemas, and Jest unit tests.
When to Use
- Creating new entity modules with full CRUD endpoints
- Building database-backed features in NestJS
- Generating type-safe DTOs with Zod validation
- Adding services with Drizzle ORM queries
- Creating unit tests with mocked database
Instructions
Step 1: Define Entity Fields
Gather entity definition:
- Entity name (e.g.,
user,product,order) - List of fields with types (see
references/field-types.mdfor supported types) - Required fields vs optional fields with defaults
Step 2: Run the Generator
python scripts/generate_crud.py --feature <name> --fields '<json-array>' --output <path>
Step 3: Verify Generated Files
Check that all expected files were created:
ls -la libs/server/<feature-name>/src/lib/
Expected structure:
controllers/
services/
dto/
schema/
<feature>-feature.module.ts
Step 4: Run TypeScript Compilation
cd libs/server && npx tsc --noEmit
Step 5: Execute Unit Tests
cd libs/server && npm test -- --testPathPattern=<feature-name>
Examples
Generate a User module
python scripts/generate_crud.py \
--feature user \
--fields '[{"name": "name", "type": "string", "required": true}, {"name": "email", "type": "email", "required": true}, {"name": "password", "type": "string", "required": true}]' \
--output ./libs/server
Generate a Product module
python scripts/generate_crud.py \
--feature product \
--fields '[{"name": "title", "type": "string", "required": true}, {"name": "price", "type": "number", "required": true}, {"name": "description", "type": "text", "required": false}, {"name": "inStock", "type": "boolean", "required": false, "default": true}]' \
--output ./libs/server
Generated Structure
libs/server/{feature-name}/
├── src/
│ ├── index.ts
│ └── lib/
│ ├── {feature}-feature.module.ts
│ ├── controllers/
│ │ ├── index.ts
│ │ └── {feature}.controller.ts
│ ├── services/
│ │ ├── index.ts
│ │ ├── {feature}.service.ts
│ │ └── {feature}.service.spec.ts
│ ├── dto/
│ │ ├── index.ts
│ │ └── {feature}.dto.ts
│ └── schema/
│ └── {feature}.table.ts
Features
Module
- Uses
forRootAsyncpattern for lazy configuration - Exports generated service for other modules
- Imports DatabaseModule for feature tables
Controller
- Full CRUD endpoints: POST, GET, PATCH, DELETE
- Query parameter validation for pagination
- Zod validation pipe integration
Service
- Drizzle ORM query methods
- Soft delete support (via
deletedAtcolumn) - Pagination with limit/offset
- Filtering support
- Type-safe return types
DTOs
- Zod schemas for Create and Update
- Query parameter schemas for filtering
- NestJS DTO integration
Tests
- Jest test suite
- Mocked Drizzle database
- Test cases for all CRUD operations
Manual Integration
After generation, integrate into your app module:
// app.module.ts
import { {{FeatureName}}FeatureModule } from '@your-org/server-{{feature}}';
@Module({
imports: [
{{FeatureName}}FeatureModule.forRootAsync({
useFactory: () => ({
defaultPageSize: 10,
maxPageSize: 100,
}),
}),
],
})
export class AppModule {}
Dependencies
Required packages:
@nestjs/common@nestjs/coredrizzle-ormdrizzle-zodzodnestjs-zod
Best Practices
- Verify before commit: Always run
tsc --noEmitand tests before committing generated code - Customize services: Add business logic to generated services after validation
- Database migrations: Create migrations separately for generated Drizzle schemas
- Use generated types: Reference generated types in your application code
- Review DTOs: Adjust Zod validation rules based on your API requirements
Constraints and Warnings
- Soft delete only: Delete operations use soft delete (
deletedAttimestamp). Hard deletes require manual modification - No authentication: Generated code does not include auth guards - add them based on your security requirements
- Basic CRUD only: Complex queries, transactions, or business logic must be implemented manually
- JSON escaping: Use single quotes around the JSON array when passing fields on command line
Related skills
More from giuseppe-trisciuoglio/developer-kit and the wider catalog.

nextjs-app-router
Patterns and code examples for Next.js 16+ App Router architecture with Server Components, Server Actions, and caching.

nextjs-authentication
Auth.js 5 authentication patterns for Next.js 15+ App Router with OAuth, protected routes, and RBAC.

nextjs-code-review
Comprehensive code review for Next.js App Router applications with best-practice validation.

nextjs-data-fetching
Next.js App Router data fetching patterns: server/client strategies, SWR, React Query, ISR, and revalidation.

nextjs-deployment
Deploy Next.js apps to production with Docker, CI/CD pipelines, health checks, and OpenTelemetry monitoring.

nextjs-performance
Expert Next.js performance optimization for Core Web Vitals, images, fonts, caching, and Server Components.