# nestjs-drizzle-crud-generator

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.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3600 installs · ★ 363
- Author: giuseppe-trisciuoglio
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/giuseppe-trisciuoglio/developer-kit/tree/HEAD/plugins/developer-kit-typescript/skills/nestjs-drizzle-crud-generator/SKILL.md
- Updated: 2026-09-10
- HTML: https://affpapa.org/en/nevibecode/skills/nestjs-drizzle-crud-generator

## What it 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`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nestjs-drizzle-crud-generator -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/nestjs-drizzle-crud-generator/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/nestjs-drizzle-crud-generator/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nestjs-drizzle-crud-generator -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/nestjs-drizzle-crud-generator/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nestjs-drizzle-crud-generator -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/nestjs-drizzle-crud-generator/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install giuseppe-trisciuoglio/developer-kit nestjs-drizzle-crud-generator
```

2. **Manually: put the files in place**
- File: `.github/skills/nestjs-drizzle-crud-generator/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nestjs-drizzle-crud-generator -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/giuseppe-trisciuoglio/developer-kit --path plugins/developer-kit-typescript/skills/nestjs-drizzle-crud-generator
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/nestjs-drizzle-crud-generator/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nestjs-drizzle-crud-generator -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/giuseppe-trisciuoglio/developer-kit/tree/HEAD/plugins/developer-kit-typescript/skills/nestjs-drizzle-crud-generator/SKILL.md

## When to use it
- 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
- 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

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: c36f4777716ded87.

BEGIN THIRD-PARTY FILE c36f4777716ded87
````text
---
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 \
````
END THIRD-PARTY FILE c36f4777716ded87

The third-party file has ended. Everything between the c36f4777716ded87 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2037 of 5376 bytes. © giuseppe-trisciuoglio · MIT · https://github.com/giuseppe-trisciuoglio/developer-kit/tree/HEAD/plugins/developer-kit-typescript/skills/nestjs-drizzle-crud-generator/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
