home / skills / ehtbanton / claudeskillsrepo / nestjs-module-generator

nestjs-module-generator skill

/nestjs-module-generator

This skill generates a complete NestJS module with controller, service, DTOs, and entity files following best practices.

npx playbooks add skill ehtbanton/claudeskillsrepo --skill nestjs-module-generator

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
748 B
---
name: nestjs-module-generator
description: Generate NestJS module files with controllers, services, DTOs, and entities. Triggers on "create nestjs module", "generate nest module", "nestjs resource", "nest crud module".
---

# NestJS Module Generator

Generate complete NestJS modules with controllers, services, DTOs, and entity files.

## Output Requirements

**File Output:** `*.module.ts`, `*.controller.ts`, `*.service.ts`, `*.dto.ts`
**Format:** Valid NestJS TypeScript
**Standards:** NestJS best practices

## When Invoked

Immediately generate a complete NestJS module with all required files.

## Example Invocations

**Prompt:** "Create NestJS module for orders"
**Output:** Complete module with controller, service, DTOs, and entity.

Overview

This skill generates complete NestJS modules ready for immediate use in a TypeScript project. It produces module, controller, service, DTO, and entity files following NestJS conventions and best practices. Use simple trigger phrases like "create nestjs module" or "generate nest module" to produce a full resource scaffold. The output is valid TypeScript tailored for common CRUD patterns.

How this skill works

When invoked, the skill creates a set of files: *.module.ts, *.controller.ts, *.service.ts, *.dto.ts, and an entity file. Each file follows NestJS structure and wiring: controllers inject services, services handle business logic, DTOs validate and type input, and entities define persistence models. The generated code is idiomatic TypeScript that integrates with typical NestJS setups (providers, exports, imports).

When to use it

  • Scaffolding a new resource quickly (e.g., orders, users, products).
  • Starting a CRUD endpoint with DTO validation and persistence models.
  • Prototyping APIs to validate domain models and request/response shapes.
  • Standardizing module layout across a NestJS codebase.
  • Onboarding new projects to ensure consistent file patterns.

Best practices

  • Provide the resource name and desired fields to generate meaningful DTOs and entities.
  • Review and adapt generated entity decorators for your ORM (TypeORM, Sequelize, Prisma).
  • Add explicit validation decorators in DTOs and adjust service stubs to match business rules.
  • Keep controller methods thin; move logic to services and inject repositories via providers.
  • Run static type checks and linting after generation to align with project config.

Example use cases

  • Create NestJS module for orders with id, customerId, total, and status fields.
  • Generate nest module for a user resource including create/update DTOs and a User entity.
  • Nest crud module for products with search and pagination-ready controller methods.
  • Generate a module scaffold during sprint planning to speed backend implementation.

FAQ

Can I customize ORM decorators or types?

Yes. The generator produces common entity shapes; update decorators and types to match your chosen ORM and database schema.

Does the skill wire up routing and providers?

Generated modules include standard NestJS imports, controllers, and providers. You still need to register the module in your application module if not automated.

Will DTOs include validation?

DTOs include common validation decorators. Adjust constraints and add custom validators as needed for business rules.