nestjs-architecture-guardian
Skill17 starsChanged 59 days agoMITView on GitHub
Enforce clean NestJS architecture, module boundaries, provider discipline, DTO separation, and maintainable application structure.
In this repository22 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- adr-challengerSkill
- api-designSkill
- architecture-decisionsSkill
- async-systemsSkill
- code-reviewSkill
- database-engineeringSkill
- dora-metricsSkill
- engineering-economicsSkill
- incident-responseSkill
- node-runtime-reliabilitySkill
- observabilitySkill
- performance-analysisSkill
- prd-reviewSkill
- production-readinessSkill
- release-planningSkill
- repo-onboardingSkill
- safe-refactoringSkill
- security-reviewSkill
- systematic-debuggingSkill
- test-strategySkill
The file
Files
Mission
Protect NestJS services from architectural entropy, framework misuse, and business logic leakage.
When to use
- Designing or reviewing NestJS modules.
- Implementing new features.
- Refactoring NestJS services.
- Evaluating layering and dependency discipline.
Handoff
- Receives from: backend-platform-engineer (implementation task).
- Hands off to: code-review (for review), test-strategy (for test plan).
Layer rules
Controller (thin) → Application Service → Domain Service → Repository
↓ ↓ ↓ ↓
Transport Orchestration Business rules Persistence
Validation Use cases Pure logic Data access
Auth guards Event emission No framework No business logicWhat belongs where
| Layer | YES | NO |
| Controller | Route, validate DTO, call service, return response | Business rules, DB queries, event logic |
| Application Service | Orchestrate use case, call domain + repo, emit events | HTTP concepts, raw SQL, framework decorators |
| Domain Service | Business rules, calculations, validations | DB calls, HTTP, queue, framework imports |
| Repository | Query, save, transaction management | Business rules, validation, HTTP |
| DTO | Input/output shape for transport | Domain model replacement |
| Entity/Model | Database shape | Business logic, validation rules |
Red flags
- Controller with more than 15 lines of logic.
- Service that imports
@Res(),@Req(), or HTTP-specific types. - Repository that contains
ifstatements about business rules. - DTO class reused as domain model throughout the codebase.
- "Common" or "shared" module with 20+ exports.
- Circular dependency between modules.
- Guard or interceptor containing business logic.
Module boundary check
- Can this module be extracted to a separate package without breaking others?
- Does this module export only what other modules actually need?
- Are cross-module imports going through the public API (exported services), not internal files?
Output format
- Architectural assessment (clean / has drift / needs refactor)
- Boundary violations (specific file + line if possible)
- Layer misplacements (what's in the wrong layer, where it should go)
- Coupling risks (hidden dependencies)
- Suggested target structure (concrete folder/file layout)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

