Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Provides implementation patterns for Clean Architecture, Hexagonal Architecture (Ports & Adapters), and Domain-Driven Design in Java 21+ Spring Boot 3.5+ applications. Use when structuring layered architectures, separating domain logic from frameworks, implementing ports and adapters, creating entities/value objects/aggregates, or refactoring monolithic codebases for testability and maintainability.
.claude/skills/giuseppe-trisciuoglio-clean-architecture/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-16 | ✗→✓ | ▲ Improved | 12% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 41% | 0% |
| case-07 | ✓→✓ | = Same ✓ | 32% | 0% |
| case-19 | ✓→✓ | = Same ✓ | 44% | 0% |
| case-20 | ✓→✓ | = Same ✓ | 110% | 0% |
This skill provides comprehensive guidance for implementing Clean Architecture, Domain-Driven Design (DDD), and Hexagonal Architecture patterns in NestJS/TypeScript applications. It covers the architectural layers, tactical patterns, and practical implementation examples for building maintainable, testable, and loosely-coupled backend systems.
Clean Architecture organizes code into concentric layers where dependencies flow inward. Inner layers have no knowledge of outer layers:
+-------------------------------------+
| Infrastructure (Frameworks, DB) | Outer layer - volatile
+-------------------------------------+
| Adapters (Controllers, Repositories)| Interface adapters
+-------------------------------------+
| Application (Use Cases) | Business rules
+-------------------------------------+
| Domain (Entities, Value Objects) | Core - most stable
+-------------------------------------+The Hexagonal Architecture (Ports & Adapters) pattern complements this:
Apply these patterns in your domain layer:
Structure your NestJS project following Clean Architecture principles:
src/
+-- domain/ # Inner layer - no external deps
| +-- entities/ # Domain entities
| +-- value-objects/ # Immutable value objects
| +-- aggregates/ # Aggregate roots
| +-- events/ # Domain events
| +-- repositories/ # Repository interfaces (ports)
| +-- services/ # Domain services
+-- application/ # Use cases - orchestration
| +-- use-cases/ # Individual use cases
| +-- ports/ # Input/output ports
| +-- dto/ # Application DTOs
| +-- services/ # Application services
+-- infrastructure/ # External concerns
| +-- database/ # ORM config, migrations
| +-- http/ # HTTP clients
| +-- messaging/ # Message queues
+-- adapters/ # Interface adapters
+-- http/ # Controllers, presenters
+-- persistence/ # Repository implementations
+-- external/ # External service adaptersCreate pure domain objects with no external dependencies:
Create use cases that orchestrate business logic:
execute methodCreate concrete implementations of ports:
Wire everything together in NestJS modules:
Follow these principles throughout implementation:
For detailed code examples covering all aspects of Clean Architecture implementation, see:
For comprehensive guidance on Clean Architecture best practices, including:
See references/best-practices.md
Important constraints, common pitfalls, and implementation warnings:
See references/constraints.md
references/examples.md - Complete code examples for all layersreferences/best-practices.md - Comprehensive best practices and principlesreferences/constraints.md - Constraints, pitfalls, and warnings| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 43,346 | 14,386 | -67% | 1 | 1 | 0% | 2,976 | 4,188 | +41% | 0 | 0 | — |
case-07 | pass→pass | 15,360 | 9,972 | -35% | 1 | 1 | 0% | 2,552 | 3,366 | +32% | 0 | 0 | — |
case-19 | pass→pass | 13,328 | 8,964 | -33% | 1 | 1 | 0% | 2,035 | 2,927 | +44% | 0 | 0 | — |
case-20 | pass→pass | 7,548 | 8,799 | +17% | 1 | 1 | 0% | 1,516 | 3,186 | +110% | 0 | 0 | — |
case-02 | pass→pass | 13,734 | 9,246 | -33% | 1 | 1 | 0% | 2,499 | 3,051 | +22% | 0 | 0 | — |
case-03 | pass→pass | 11,782 | 9,586 | -19% | 1 | 1 | 0% | 2,095 | 3,452 | +65% | 0 | 0 | — |
case-04 | pass→pass | 12,076 | 12,032 | -0% | 1 | 1 | 0% | 2,245 | 3,915 | +74% | 0 | 0 | — |
case-05 | pass→pass | 28,488 | 9,891 | -65% | 1 | 1 | 0% | 2,728 | 3,642 | +34% | 0 | 0 | — |
case-06 | pass→pass | 11,282 | 10,960 | -3% | 1 | 1 | 0% | 1,885 | 3,433 | +82% | 0 | 0 | — |
case-08 | pass→pass | 17,174 | 12,886 | -25% | 1 | 1 | 0% | 3,300 | 4,147 | +26% | 0 | 0 | — |
case-09 | pass→pass | 14,052 | 10,064 | -28% | 1 | 1 | 0% | 2,264 | 3,324 | +47% | 0 | 0 | — |
case-10 | pass→pass | 14,188 | 9,643 | -32% | 1 | 1 | 0% | 2,402 | 3,161 | +32% | 0 | 0 | — |
case-11 | pass→pass | 24,391 | 16,664 | -32% | 1 | 1 | 0% | 3,062 | 4,581 | +50% | 0 | 0 | — |
case-12 | pass→pass | 16,468 | 12,353 | -25% | 1 | 1 | 0% | 2,612 | 3,675 | +41% | 0 | 0 | — |
case-13 | pass→pass | 11,108 | 9,521 | -14% | 1 | 1 | 0% | 2,136 | 3,269 | +53% | 0 | 0 | — |
case-14 | pass→pass | 11,978 | 9,514 | -21% | 1 | 1 | 0% | 2,019 | 3,070 | +52% | 0 | 0 | — |
case-15 | pass→pass | 12,452 | 11,479 | -8% | 1 | 1 | 0% | 1,978 | 3,502 | +77% | 0 | 0 | — |
case-16 | fail→pass | 16,829 | 8,884 | -47% | 1 | 1 | 0% | 2,804 | 3,138 | +12% | 0 | 0 | — |
case-17 | pass→pass | 14,582 | 13,423 | -8% | 1 | 1 | 0% | 2,325 | 3,929 | +69% | 0 | 0 | — |
case-18 | pass→pass | 29,609 | 15,568 | -47% | 1 | 1 | 0% | 2,987 | 4,237 | +42% | 0 | 0 | — |
case-21 | pass→pass | 6,043 | 5,452 | -10% | 1 | 1 | 0% | 1,169 | 2,439 | +109% | 0 | 0 | — |
case-22 | pass→pass | 6,120 | 5,273 | -14% | 1 | 1 | 0% | 1,191 | 2,494 | +109% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.