Back to skills
SKILL.md
Nestjs Patterns
ASecurityUse when building NestJS APIs with modules, validation, guards, config, and testing. Triggers on \"nestjs-patterns\", \"nestjs patterns\", \"patterns\".
- 2 stars
- 0 votes
- 0 copies
- 2 views
- Added September 19, 2026
Works with
Security analysis
100/100Pro scans all 5 files and shows the line behind each finding
npx -y skills add majinmagros/magros.ai-skills --skill nestjs-patterns --agent claude-codeAre you the author of Nestjs Patterns?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/majinmagros-nestjs-patterns)---
name: nestjs-patterns
description: "Use when building NestJS APIs with modules, validation, guards, config, and testing. Triggers on \"nestjs-patterns\", \"nestjs patterns\", \"patterns\"."
metadata:
origin: ECC
---
# NestJS Development Patterns
Modular TypeScript backends: thin controllers, validated DTOs, guarded routes. Detalhes em `references/`.
## When to Activate
- Building NestJS APIs or services
- Structuring modules, controllers, and providers
- Adding DTO validation, guards, interceptors, or exception filters
- Configuring environment-aware settings and database integrations
- Testing NestJS units or HTTP endpoints
## Core Principles
1. **Thin controllers** — parse input, call service, return response DTO
2. **Validate globally** — one ValidationPipe with whitelist + forbidNonWhitelisted
3. **Guards coarse, services fine** — roles in guards, ownership in services
4. **One error envelope** — central filter; never leak hashes/tokens
5. **Env fails at boot** — typed config; transactions owned by services
## Example
```ts
@Post()
create(@Body() dto: CreateUserDto) {
return this.usersService.create(dto);
}
```
## References
- `references/structure-bootstrap.md` — feature-module layout, global ValidationPipe bootstrap
- `references/modules-controllers.md` — module/controller/service split, class-validator DTOs
- `references/auth-errors-config.md` — guards, exception filter, env validation, transactions
- `references/testing-production.md` — TestingModule patterns, logging, health, jobs, rate limits
## Checklist
- [ ] Global pipe: whitelist + forbidNonWhitelisted + transform
- [ ] No business logic in controllers; no ORM entities in responses
- [ ] Guards + service-level authorization both present
- [ ] Single error envelope; env validated at boot
- [ ] Tests reuse production pipes/filters
Files in this skill
- SKILL.md
- references/auth-errors-config.md
- references/modules-controllers.md
- references/structure-bootstrap.md
- references/testing-production.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.