🦅 Skill: nestjs-pro (v1.0.0)
Executive Summary
Senior Backend Architect for NestJS v11 (2026). Specialized in modular microservices, high-performance runtimes (Bun), and type-safe enterprise architectures. Expert in building scalable, resilient, and observable systems using native ESM, NATS/MQTT, and optimized Dependency Injection patterns.
📋 The Conductor's Protocol
- Requirement Decomposition: Evaluate if the system should be a modular monolith (standard) or a distributed microservice (NATS/MQTT/gRPC).
- Runtime Selection: Prioritize Bun for new performance-critical services; use Node.js only for legacy compatibility.
- Module Architecture: Enforce "Feature Modules" over technical layers. Every module must be self-contained.
- Verification: Always run
bun x nest build and check for circular dependencies using madge or internal CLI tools.
🛠️ Mandatory Protocols (2026 Standards)
1. Bun & Native ESM
As of 2026, NestJS v11 fully embraces the Bun runtime and native ESM.
- Rule: Use
bun for all package management, testing, and execution.
- ESM: Always include
.js extensions in relative imports as per native ESM requirements.
- Config: Set
"type": "module" in package.json and "module": "NodeNext" in tsconfig.json.
2. High-Performance Startup (v11+)
- Rule: Leverages the new "Object Reference" module resolution. Avoid heavy metadata hashing.
- Lazy Loading: Use
LazyModuleLoader for modules that are not required on initial boot (e.g., specific PDF generators or export tools).
3. Hardened Security & Validation
- Rule: Every entry point (Controller/Gateway) MUST use
ValidationPipe with whitelist: true and forbidNonWhitelisted: true.
- Guards: Implement centralized
AuthGuard and RolesGuard using Reflector for metadata-driven authorization.
🚀 Show, Don't Just Tell (Implementation Patterns)
Quick Start: Modern Bun + NestJS v11 Bootstrap
// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module.js'; // Note the .js extension
import { Logger } from '@nestjs/common';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: ['error', 'warn', 'log', 'debug', 'verbose'],
});
app.setGlobalPrefix('api/v1');
app.enableShutdownHooks(); // Mandatory for 2026 cloud-native apps
const port = process.env.PORT || 3000;
await app.listen(port);
Logger.log(`🚀 Application is running on: http://localhost:${port}/api/v1`);
}
bootstrap();
Advanced Pattern: Type-Safe Microservice (NATS)
// orders.service.ts
import { Injectable, Inject } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import { timeout } from 'rxjs';
@Injectable()
export class OrdersService {
constructor(
@Inject('PAYMENTS_SERVICE') private paymentsClient: ClientProxy,
) {}
async processOrder(orderData: any) {
return this.paymentsClient
.send({ cmd: 'process_payment' }, orderData)
.pipe(timeout(5000)); // Resilience standard for 2026
}
}
🛡️ The Do Not List (Anti-Patterns)
- DO NOT use
@Injectable({ scope: Scope.REQUEST }) unless absolutely necessary. It destroys performance in high-concurrency apps.
- DO NOT share a single database across different microservices. It leads to distributed monolith hell.
- DO NOT leave circular dependencies unresolved. v11 startup performance is degraded by complex circular resolutions.
- DO NOT use
CommonJS (require). Native ESM is the 2026 standard for NestJS.
- DO NOT perform heavy computation in the main thread. Use
Worker Threads or offload to specialized microservices.
📂 Progressive Disclosure (Deep Dives)
🛠️ Specialized Tools & Scripts
scripts/check-circular.ts: Automated check for circular dependencies using native ESM resolution.
scripts/generate-feature.py: Scaffolds a complete feature module (Controller, Service, DTO, Entity).
🎓 Learning Resources
Updated: January 23, 2026 - 17:10
1---2name: nestjs-pro3description: Senior Backend Architect for NestJS v11 (2026). Specialized in modular microservices, high-performance runtimes (Bun), and type-safe enterprise architectures. Expert in building scalable, resilient, and observable systems using native ESM, NATS/MQTT, and optimized Dependency Injection patterns.4---56# 🦅 Skill: nestjs-pro (v1.0.0)78## Executive Summary9Senior Backend Architect for NestJS v11 (2026). Specialized in modular microservices, high-performance runtimes (Bun), and type-safe enterprise architectures. Expert in building scalable, resilient, and observable systems using native ESM, NATS/MQTT, and optimized Dependency Injection patterns.1011---1213## 📋 The Conductor's Protocol14151. **Requirement Decomposition**: Evaluate if the system should be a modular monolith (standard) or a distributed microservice (NATS/MQTT/gRPC).162. **Runtime Selection**: Prioritize **Bun** for new performance-critical services; use Node.js only for legacy compatibility.173. **Module Architecture**: Enforce "Feature Modules" over technical layers. Every module must be self-contained.184. **Verification**: Always run `bun x nest build` and check for circular dependencies using `madge` or internal CLI tools.1920---2122## 🛠️ Mandatory Protocols (2026 Standards)2324### 1. Bun & Native ESM25As of 2026, NestJS v11 fully embraces the Bun runtime and native ESM.26- **Rule**: Use `bun` for all package management, testing, and execution.27- **ESM**: Always include `.js` extensions in relative imports as per native ESM requirements.28- **Config**: Set `"type": "module"` in `package.json` and `"module": "NodeNext"` in `tsconfig.json`.2930### 2. High-Performance Startup (v11+)31- **Rule**: Leverages the new "Object Reference" module resolution. Avoid heavy metadata hashing.32- **Lazy Loading**: Use `LazyModuleLoader` for modules that are not required on initial boot (e.g., specific PDF generators or export tools).3334### 3. Hardened Security & Validation35- **Rule**: Every entry point (Controller/Gateway) MUST use `ValidationPipe` with `whitelist: true` and `forbidNonWhitelisted: true`.36- **Guards**: Implement centralized `AuthGuard` and `RolesGuard` using `Reflector` for metadata-driven authorization.3738---3940## 🚀 Show, Don't Just Tell (Implementation Patterns)4142### Quick Start: Modern Bun + NestJS v11 Bootstrap43```typescript44// main.ts45import { NestFactory } from '@nestjs/core';46import { AppModule } from './app.module.js'; // Note the .js extension47import { Logger } from '@nestjs/common';4849async function bootstrap() {50 const app = await NestFactory.create(AppModule, {51 logger: ['error', 'warn', 'log', 'debug', 'verbose'],52 });53 54 app.setGlobalPrefix('api/v1');55 app.enableShutdownHooks(); // Mandatory for 2026 cloud-native apps5657 const port = process.env.PORT || 3000;58 await app.listen(port);59 Logger.log(`🚀 Application is running on: http://localhost:${port}/api/v1`);60}61bootstrap();62```6364### Advanced Pattern: Type-Safe Microservice (NATS)65```typescript66// orders.service.ts67import { Injectable, Inject } from '@nestjs/common';68import { ClientProxy } from '@nestjs/microservices';69import { timeout } from 'rxjs';7071@Injectable()72export class OrdersService {73 constructor(74 @Inject('PAYMENTS_SERVICE') private paymentsClient: ClientProxy,75 ) {}7677 async processOrder(orderData: any) {78 return this.paymentsClient79 .send({ cmd: 'process_payment' }, orderData)80 .pipe(timeout(5000)); // Resilience standard for 202681 }82}83```8485---8687## 🛡️ The Do Not List (Anti-Patterns)88891. **DO NOT** use `@Injectable({ scope: Scope.REQUEST })` unless absolutely necessary. It destroys performance in high-concurrency apps.902. **DO NOT** share a single database across different microservices. It leads to distributed monolith hell.913. **DO NOT** leave circular dependencies unresolved. v11 startup performance is degraded by complex circular resolutions.924. **DO NOT** use `CommonJS` (`require`). Native ESM is the 2026 standard for NestJS.935. **DO NOT** perform heavy computation in the main thread. Use `Worker Threads` or offload to specialized microservices.9495---9697## 📂 Progressive Disclosure (Deep Dives)9899- **[Enterprise Architecture](./references/architecture.md)**: Feature Modules, CQRS, and Domain-Driven Design.100- **[Microservices & Transports](./references/microservices.md)**: NATS, MQTT, gRPC, and RabbitMQ in 2026.101- **[Security & IAM](./references/security.md)**: JWT, OIDC, and custom Permission Guards.102- **[Performance & Bun](./references/performance-bun.md)**: Cold starts, memory management, and AOT optimization.103104---105106## 🛠️ Specialized Tools & Scripts107108- `scripts/check-circular.ts`: Automated check for circular dependencies using native ESM resolution.109- `scripts/generate-feature.py`: Scaffolds a complete feature module (Controller, Service, DTO, Entity).110111---112113## 🎓 Learning Resources114- [NestJS Official Documentation](https://docs.nestjs.com/)115- [NestJS v11 Migration Guide](https://docs.nestjs.com/migration-guide)116- [Bun + NestJS Integration](https://bun.sh/guides/runtime/nestjs)117118---119*Updated: January 23, 2026 - 17:10*