Skip to main content
skill CX Codex

nestjs-drizzle-crud-generator — Codex skill

Writes a NestJS feature module against Drizzle ORM: controller, service, Zod DTOs and Jest tests, driven by a field list you supply. Handy when a new API section has to land fast.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add giuseppe-trisciuoglio/developer-kit --skill nestjs-drizzle-crud-generator -a claude-code
Open on GitHub

What nestjs-drizzle-crud-generator does

The skill calls a Python generator (scripts/generate_crud.py) and drops the output under libs/server/<feature-name>/. You describe the entity as a JSON array: each field gets a name, a type and whether it is required. A table schema, a module file and specs come along with the main pieces.

The controller exposes POST, GET, PATCH and DELETE, validates pagination query params and wires in the Zod pipe. The service runs Drizzle queries with limit/offset, supports filtering and deletes softly through the deletedAt column. DTOs are built from Zod schemas for create and update.

Wiring stays manual: add the module to app.module.ts with forRootAsync. No auth guards ship with the code. Want a hard delete? You write it yourself, because the generated path only sets deletedAt. Run npx tsc --noEmit and the tests before committing, and create the DB migrations for the schema separately. Required packages include drizzle-orm, drizzle-zod, zod and nestjs-zod.

What it helps with

  • scaffold a NestJS module for a new table in one pass
  • get Zod-validated DTOs without writing them by hand
  • add limit/offset pagination and filtering to a Drizzle service
  • cover CRUD methods with Jest specs on a mocked database
  • delete rows softly via the deletedAt column

Example prompts for the agent

  • Generate a NestJS CRUD module for an order entity with number and total fields, output to ./libs/server
  • Add an article entity to NestJS with required title and body
  • Regenerate the product module and include sku as a string field

How to install nestjs-drizzle-crud-generator

1Skills CLI (Vercel)

npx skills add giuseppe-trisciuoglio/developer-kit --skill nestjs-drizzle-crud-generator -a claude-code

2Manually: put the files in place

~/.claude/skills/nestjs-drizzle-crud-generator/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/nestjs-drizzle-crud-generator/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about nestjs-drizzle-crud-generator

How do I install nestjs-drizzle-crud-generator in Claude Code?

Run npx skills add giuseppe-trisciuoglio/developer-kit --skill nestjs-drizzle-crud-generator -a claude-code. The skill file lands at ~/.claude/skills/nestjs-drizzle-crud-generator/SKILL.md.

What does nestjs-drizzle-crud-generator do?

It creates a full NestJS CRUD feature: controller, Drizzle-backed service, Zod DTOs, table schema and Jest tests. You hand it the entity fields as a list.

What does the skill need to run?

The Python generator script, plus drizzle-orm, drizzle-zod, zod and nestjs-zod in the project. Tests run through npm; migrations for the generated schema you create yourself.

Source text

SKILL.md · MIT
---
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.md` for supported types)
- Required fields vs optional fields with defaults

### Step 2: Run the Generator

```bash
python scripts/generate_crud.py --feature <name> --fields '<json-array>' --output <path>
```

### Step 3: Verify Generated Files

Check that all expected files were created:

```bash
ls -la libs/server/<feature-name>/src/lib/
```

Expected structure:
```
controllers/
services/
dto/
schema/
<feature>-feature.module.ts
```

### Step 4: Run TypeScript Compilation

```bash
cd libs/server && npx tsc --noEmit
```

### Step 5: Execute Unit Tests

```bash
cd libs/server && npm test -- --testPathPattern=<feature-name>
```

## Examples

### Generate a User module

```bash
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

```bash
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 `forRootAsync` pattern 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 `deletedAt` column)
- 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:

```typescript
// 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/core`
- `drizzle-orm`
- `drizzle-zod`
- `zod`
- `nestjs-zod`

## Best Practices

1. **Verify before commit**: Always run `tsc --noEmit` and tests before committing generated code
2. **Customize services**: Add business logic to generated services after validation
3. **Database migrations**: Create migrations separately for generated Drizzle schemas
4. **Use generated types**: Reference generated types in your application code
5. **Review DTOs**: Adjust Zod validation rules based on your API requirements

## Constraints and Warnings

- **Soft delete only**: Delete operations use soft delete (`deletedAt` timestamp). 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

© giuseppe-trisciuoglio · MIT · giuseppe-trisciuoglio/developer-kit

Similar skills

All skills for Backend and APIs →

From the same set96

sonarqube-mcp Checks quality gates, finds SonarQube and SonarCloud issues, and explains rules before code is pushed. Use it when an agent needs project or pull request quality feedback. CX Codex +1 3,600installs better-auth A skill with ready-made Better Auth patterns: NestJS backend, Drizzle ORM and PostgreSQL, social login, plus plugins like 2FA and passkey. CX Codex +1 3,600installs aws-lambda-typescript-integration Provides AWS Lambda integration patterns for TypeScript, comparing NestJS and raw handlers with cold start optimization guidelines. CX Codex +1 3,600installs aws-lambda-python-integration Tells the agent how to build and ship Python functions on AWS Lambda: Chalice or raw Python, cold start tuning, API Gateway and ALB wiring. CX Codex +1 3,600installs graalvm-native-image Guides the ahead-of-time compilation of Java applications into native executables with GraalVM. Useful when cutting cold start latency and memory usage in microservices. CX Codex +1 3,500installs memory-md-management This skill scans project memory files such as CLAUDE.md, scores them against six criteria and proposes targeted edits. CX Codex +1 3,500installs dynamodb-toolbox-patterns A skill with TypeScript patterns for DynamoDB-Toolbox v2: schemas, entities, .build() commands, queries and transactions. CX Codex +1 3,500installs github-issue-workflow An 8-phase workflow that takes GitHub issues from description to pull request. It isolates untrusted prompt text, enforces testing, and coordinates code review. CX Codex +1 3,500installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor