---
name: "nestjs-modular-dependency-injection"
description: "Architect scalable enterprise backend applications using NestJS modules, providers, and DI."
metadata:
  author: "Kamil Mysliwiec"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "create nestjs module"
  - "custom provider usefactory nestjs"
  - "dynamic module nestjs"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# NestJS Modular Architecture & Dependency Injection (DI)

Constructs NestJS applications: @Module decorators (imports, controllers, providers, exports), constructor dependency injection, custom providers (useClass, useFactory, useValue), and dynamic modules (forRoot / register).

## When to Invoke
Invoke this skill whenever you need to:
- create nestjs module
- custom provider usefactory nestjs
- dynamic module nestjs

## Execution SOP & Rules
1. Decorate feature classes with @Injectable() to register them with the NestJS IoC container.
2. Inject dependencies via constructor: constructor(private readonly usersService: UsersService) {}.
3. Export providers in @Module({ exports: [UsersService] }) to make them available to importing modules.
4. Implement ConfigModule.forRoot({ isGlobal: true }) to provide environment config application-wide.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
