clean-architecture

Organize NestJS/TypeScript backends with Clean Architecture, DDD, and Hexagonal patterns.

Updated May 17, 2026
One-click install
npx skills add https://github.com/cenjie/skills --skill clean-architecture-cenjie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-architecture
Source: https://github.com/cenjie/skills/tree/main/skills/clean-architecture
Command: npx skills add https://github.com/cenjie/skills --skill clean-architecture-cenjie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill helps teams organize large NestJS/TypeScript backends by separating domain logic from infrastructure, enabling maintainable domain models, clear boundaries, and easier testing.

Core Features & Use Cases

  • Architectural guidance for Clean Architecture, DDD, and Hexagonal patterns in NestJS/TypeScript.
  • Template project structure and tactical patterns for entities, value objects, aggregates, ports, and adapters.
  • Real-world use case: modeling a domain with bounded contexts and domain events, then wiring use cases to adapters and repositories.

Quick Start

Begin by defining domain boundaries (entities, value objects, aggregates), declare ports for data access, implement use cases, and wire adapters to connect domain to infrastructure.

Frequently Asked Questions about clean-architecture

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

FAQPage Schema
How do I structure a NestJS backend with Clean Architecture and DDD?

Structure a NestJS backend with Clean Architecture by separating domain, application, and infrastructure layers. Define bounded contexts, enforce inward dependencies, and wire use cases to adapters for data access to ensure maintainable domain models.

What is the best way to implement Hexagonal Architecture in TypeScript?

Implement Hexagonal Architecture in TypeScript by defining ports for data access and implementing adapters to connect the domain to infrastructure. This isolates domain logic and promotes highly testable use cases across your application.

When do I need bounded contexts and domain events in NestJS?

You need bounded contexts and domain events in NestJS when modeling complex, maintainable domain models. This approach separates large business domains into distinct logical boundaries, ensuring clear architectural limits and easier testing.

How do I enforce inward dependencies in a TypeScript clean architecture project?

Enforce inward dependencies in a TypeScript clean architecture project by ensuring infrastructure and application layers depend on the domain layer, while the domain layer remains isolated. Declare ports for data access to maintain strict boundary separation.

Can I use NestJS dependency injection to wire adapters and repositories in Clean Architecture?

Yes, you can use NestJS dependency injection to wire adapters and repositories. Define ports in the domain layer for data access, implement adapters in the infrastructure layer, and inject them into application use cases to maintain testability.

Why does my domain logic leak into infrastructure in TypeScript applications?

Domain logic leaks into infrastructure when inward dependencies are not enforced. Apply Hexagonal Architecture patterns by defining ports for data access and keeping rich domain models with invariants isolated in the domain layer.