# Nest Module

> Generate a complete NestJS module with controller, service, and DTOs following DevPath architecture. Use when creating new backend modules. Use when this capability is needed.

- Skill: `tomevault-io/nest-module` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/nest-module`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/nest-module/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/nest-module

---


# Generate NestJS Module

Generate a complete NestJS module following the DevPath project architecture.

> **Important:** Follow the Learning Mode guidelines in `_templates/learning-mode.md`

## Arguments
- `$ARGUMENTS` - Module name (e.g., "users", "lessons", "quizzes")

## Instructions

When the user runs `/nest-module <module-name>`:

### Step 1: Plan & Confirm
First, show the user what will be created:
```
backend/src/modules/<module-name>/
├── <module-name>.module.ts
├── <module-name>.controller.ts
├── <module-name>.service.ts
├── dto/
│   ├── create-<module-name>.dto.ts
│   └── update-<module-name>.dto.ts
```

Ask: "Bạn muốn bắt đầu từ file nào? Recommend: Service (chứa core logic)"

### Step 2: Create files one by one
For EACH file:
1. Write the code (max 50 lines)
2. Explain what it does and WHY
3. Ask: "Bạn hiểu phần này chưa? Có câu hỏi gì không?"
4. Wait for confirmation before next file

## Code Standards

1. **Controller**:
   - Use `@Controller('api/v1/<module-name>')` for versioned API
   - Include decorators: `@Get`, `@Post`, `@Patch`, `@Delete`
   - Use `@ApiTags` for Swagger documentation

2. **Service**:
   - Inject `PrismaService` for database operations
   - Use async/await pattern
   - Throw proper NestJS exceptions

3. **DTOs**:
   - Use `class-validator` decorators
   - Use `class-transformer` for transformation

4. **Module**:
   - Import required modules (PrismaModule, etc.)
   - Export service if needed by other modules

## After Completion

Remind user:
- "Nhớ update TRACKPAD.md với những gì đã học!"
- Suggest next steps (register in AppModule, create Prisma model, etc.)
- Link to NestJS docs if user needs more info

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/minhnhut05) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

