Enforces strict NestJS architecture with Prisma ORM, comprehensive testing, API documentation, and automated quality gates for enterprise-grade backend development.
This skill enforces a strict, production-ready NestJS project structure with Prisma ORM integration, comprehensive testing requirements, and automated quality controls.
Guides development following enterprise NestJS patterns with:
**Before creating or modifying files, verify the project follows this structure:**
```
src/
├── modules/ # All feature modules
├── swagger/ # API documentation
test/ # E2E tests
prisma/
├── schema.prisma # Database schema
├── migrations/ # Database migrations
├── seed.ts # Database seeding
```
**Required root files:**
**When creating a new module, always generate these files:**
```
src/modules/{module-name}/
├── {module-name}.controller.ts # HTTP endpoints
├── {module-name}.service.ts # Business logic
├── {module-name}.module.ts # Module definition
├── dto/ # Data Transfer Objects
│ ├── create-{name}.dto.ts
│ └── update-{name}.dto.ts
├── entities/ # Database entities
│ └── {name}.entity.ts
├── guards/ # Route guards (if needed)
└── *.spec.ts # Unit tests for each file
```
**Naming convention:** Use kebab-case for all file names.
**Enforce these limits:**
**Example DTO:**
```typescript
import { IsString, IsEmail, MinLength } from 'class-validator';
export class CreateUserDto {
@IsString()
@MinLength(2)
name: string;
@IsEmail()
email: string;
}
```
**For every service and controller, create corresponding test files:**
**Before allowing commits, verify:**
```bash
npm run test:cov # Must show ≥80% coverage
```
**Block commits if tests fail** (automation.blockOnTestFail: true)
**When modifying database schema:**
1. Edit `prisma/schema.prisma`
2. **Do NOT auto-migrate** (automation.autoMigrateDb: false)
3. Generate migration: `npx prisma migrate dev --name {description}`
4. Generate Prisma Client: `npx prisma generate`
5. Update corresponding entity files in `src/modules/*/entities/`
**Validate Prisma schema before proceeding:**
```bash
npx prisma validate
```
**For every controller endpoint:**
1. Add Swagger decorators:
```typescript
@ApiOperation({ summary: 'Create user' })
@ApiResponse({ status: 201, description: 'User created' })
@ApiResponse({ status: 400, description: 'Invalid input' })
```
2. Auto-generate OpenAPI spec: Output to `openapi.json`
3. Validate all DTOs are documented with `@ApiProperty()`
**Before allowing code changes, validate:**
✅ Environment variables defined in `.env` and `.env.test`
✅ Prisma schema is valid
✅ All controllers have corresponding services
✅ All services have corresponding modules
✅ All DTOs use class-validator decorators
✅ TypeScript compiles without errors (`npx tsc --noEmit`)
✅ Tests pass with ≥80% coverage
**If a file exceeds 500 lines, suggest:**
**If a function exceeds 50 lines, suggest:**
**Creating a new feature module:**
```
User: "Create a posts module with CRUD operations"
Steps:
1. Create src/modules/posts/ directory
2. Generate posts.controller.ts, posts.service.ts, posts.module.ts
3. Create dto/create-post.dto.ts and dto/update-post.dto.ts
4. Create entities/post.entity.ts
5. Generate posts.service.spec.ts and posts.controller.spec.ts
6. Add Swagger decorators to controller
7. Validate structure matches requirements
```
**Adding database model:**
```
User: "Add User model to database"
Steps:
1. Edit prisma/schema.prisma with User model
2. Run npx prisma validate
3. Prompt user to run: npx prisma migrate dev --name add_user_model
4. Generate TypeScript types: npx prisma generate
5. Create src/modules/users/entities/user.entity.ts matching schema
```
❌ **Do not create** modules without corresponding test files
❌ **Do not allow** controllers without services
❌ **Do not skip** Swagger documentation for public APIs
❌ **Do not exceed** file/function line limits
❌ **Do not use** relative imports across modules (use path aliases)
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/nestjs-project-structure-enforcer-isoc9t/raw