nestjs-service-boundary-guard

Enforce clean NestJS module boundaries for controllers, services, and DTOs.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/lgerard314/global-plugin --skill nestjs-service-boundary-guard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nestjs-service-boundary-guard
Source: https://github.com/lgerard314/global-plugin/tree/main/plugin/skills/nestjs-service-boundary-guard
Command: npx skills add https://github.com/lgerard314/global-plugin --skill nestjs-service-boundary-guard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Keep NestJS codebases maintainable by ensuring each module owns a coherent domain, controllers stay thin HTTP glue, services hold all business logic, and DTOs validate everything that crosses a boundary. Triggers on any change touching modules, controllers, services, providers, or DTOs.

Core Features & Use Cases

  • Thin controllers: validate DTOs, authorize, delegate to services, and shape responses.
  • Stateless services: avoid shared mutable state; use modules to define boundaries.
  • Module export surface: publish a clear public API while hiding internals.
  • Cross-module imports: route through a feature module's exported API to maintain encapsulation.
  • Transaction placement: keep transactions in services or use-cases, not in controllers or repositories.
  • DTO validation: use class-validator decorators and ValidationPipe with whitelist/forbidNonWhitelisted.
  • Guard/interceptor/pipe scope: apply at the most specific level that achieves the goal.

Quick Start

Apply this guard to a NestJS module and refactor controllers to delegate to services while validating DTOs.

Frequently Asked Questions about nestjs-service-boundary-guard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep NestJS controllers thin and delegate business logic to services?

Transactions in NestJS should be placed in services or use-cases, not in controllers or repositories. Keeping transactions in services ensures stateless business logic encapsulation while maintaining clean module boundaries and data consistency.

What is the best way to validate DTOs in NestJS using class-validator?

The best way to validate DTOs in NestJS is using class-validator decorators combined with the ValidationPipe configured with whitelist and forbidNonWhitelisted options. This strips and rejects unauthorized properties at the boundary.

How do I manage NestJS module boundaries and cross-module imports?

Manage NestJS module boundaries by publishing a clear public API surface while hiding internal implementation details. Route all cross-module imports through a feature module's exported API to maintain strict encapsulation and domain ownership.

Where should I apply guards, interceptors, and pipes scope in NestJS?

Guards, interceptors, and pipes scope in NestJS should be applied at the most specific controller or method level that achieves the authorization and validation goal. This prevents unnecessary global overhead and enforces module boundary discipline.