| name | productionize-module |
| description | Convert a stub NestJS module (or scaffold a new one) in backend-nestjs into a production-grade module with validated DTOs, RBAC, pagination, tenant scoping, and unit tests. Invoke with the module directory name. |
| disable-model-invocation | true |
Productionize the backend module: $ARGUMENTS
Work in backend-nestjs/. Follow the reference modules (auth, case, client).
- Locate
src/modules/$ARGUMENTS/ and read its *.service.ts (find the model via
extends BaseService<Model>) and the backing model in src/models/sequelize/.
- Scaffold the productionized skeleton:
npx ts-node scripts/scaffold-module.ts $ARGUMENTS
(emits class-validator DTOs, an RBAC + paginated controller, a createOne service, and a
controller spec). Re-running is safe — it skips modules already using @Roles.
- Hand-finish domain logic the generator can't infer: real status/stage transitions, domain
methods, relations, and any SME-specified rules. Keep server-managed fields (
firmId,
createdBy, business numbers) OUT of DTOs — forbidNonWhitelisted is ON.
- Strengthen tests in
*.spec.ts: mock the model (no DB), assert pagination, 404/403 paths,
tenant isolation, and any domain method. Real assertions only.
- Verify (must all pass):
npx tsc --noEmit -p tsconfig.json · npm test · npm run build
- Report the files changed, new test count, and any SME-gated logic left as TODO. Commit with a
descriptive message only when asked.
For broad investigation use the Explore agent; for isolated build/test work delegate to the
backend-module-builder / nest-test-author subagents.