Skip to content

Domain Review

A review skill that can be executed at any point in the workflow.

  • Source code to be reviewed must exist.
  • A specific Aggregate, layer, or the entire codebase can be specified.
  • Review is performed directly from existing code even without prerequisite documents.

Consistently applying DDD tactical design principles is difficult. Problems such as ambiguous Aggregate boundaries, blurred domain event ownership, primitive types used instead of Value Objects, and business logic leaking into the Application layer are repeatedly found in code reviews.

The /domain-review skill systematically reviews existing code from Eric Evans’ DDD perspective. It examines Aggregate boundaries, event ownership, Value Object usage, layer violations, and Functorium pattern compliance through a checklist-based approach, and provides concrete improvement directions.

CategoryReview ItemDescription
Aggregate BoundaryTransactional consistencyIs only one Aggregate modified per transaction
Aggregate BoundaryID referenceAre inter-Aggregate references made only by ID (no direct references)
Aggregate BoundaryInvariant scopeAre the invariants protected by the Aggregate clear
Event OwnershipPublishing locationAre domain events published from Aggregate command methods
Event OwnershipNamingAre events named in past tense (~Event)
Value ObjectPrimitive ObsessionAre VOs used instead of primitive types (string, int, decimal)
Value ObjectValidation locationIs validation logic encapsulated within the VO
Layer ViolationDomain -> AdapterDoes the domain not depend on infrastructure technology
Layer ViolationApplication -> DomainIs there no business logic in the Application layer
Functorium PatternFin<T> returnDo command methods return Fin<Unit> or Fin<T>
Functorium Patternsealed classAre Aggregate, VO, and Event sealed
Functorium Patternprivate constructorAre VO and Entity constructors private
/domain-review Review the Product Aggregate from a DDD perspective.

Invoking /domain-review without arguments starts the skill in interactive mode to confirm the review scope.

Review results are output in checklist table format:

| Item | Status | Violation | Improvement Suggestion |
|------|--------|-----------|----------------------|
| Aggregate Boundary | PASS | -- | -- |
| Event Ownership | WARN | ... | ... |

Example 1: Beginner — Single Aggregate Review

Section titled “Example 1: Beginner — Single Aggregate Review”

The most basic review. Inspects invariants, command methods, event publishing, and Value Object usage for a single Aggregate Root.

/domain-review Review the Product Aggregate from a DDD perspective.

The skill outputs a checklist table like the following:

## Product Aggregate Review Results
| Item | Status | Violation | Improvement Suggestion |
|------|--------|-----------|----------------------|
| sealed class | PASS | Product is sealed | -- |
| private constructor | PASS | Uses private constructor | -- |
| Fin<Unit> return | PASS | Both UpdateName and UpdatePrice return Fin<Unit> | -- |
| Event publishing | PASS | AddDomainEvent called in all command methods | -- |
| Value Object usage | WARN | Description is string type | Recommend introducing ProductDescription VO |
| Invariant scope | PASS | "Price must be positive" rule encoded in Money VO | -- |
| ID reference | PASS | Category referenced only by CategoryId | -- |
### Summary
- 6 PASS, 1 WARN out of 7 total items
- Key improvement: Recommend promoting Description to VO if it has domain rules

The skill examines the Aggregate based on the following questions:

  • What invariants does the Aggregate protect?
  • Are all state changes made through command methods?
  • Do command methods publish domain events?
  • Are Value Objects used instead of primitive types?
  • Are failures explicitly expressed with Fin<Unit> or Fin<T> returns?

Example 2: Intermediate — Layer Dependency Review

Section titled “Example 2: Intermediate — Layer Dependency Review”

Reviews layer-level dependencies beyond the Aggregate. Identifies code where the domain layer depends on infrastructure, business logic that has leaked into the Application layer, and incorrect using declarations.

/domain-review Check if there's any code where the domain layer depends on infrastructure.
## Layer Dependency Review Results
### Domain -> Adapter Dependency Check
| File | Violating using | Improvement Suggestion |
|------|----------------|----------------------|
| No violations | -- | -- |
### Application -> Domain Logic Leakage Check
| File | Violating Code | Improvement Suggestion |
|------|---------------|----------------------|
| CreateOrderCommand.cs:45 | `if (order.TotalAmount > customer.CreditLimit)` | Extract to Domain Service: OrderCreditCheckService |
### Unnecessary usings for Cleanup
| File | Unnecessary using | Reason |
|------|-------------------|--------|
| No violations | -- | -- |
### Summary
- Domain -> Adapter: No violations
- Application -> Domain logic leakage: 1 issue (credit limit validation -> Recommend extracting to Domain Service)

The skill verifies the following dependency rules:

  • Domain -> Application, Adapter dependency is forbidden
  • Application -> Adapter dependency is forbidden
  • Application must not contain business logic (conditional branching, calculations) -> Move to Domain Service or Aggregate
  • Adapter inter-dependency is forbidden (Presentation <-> Persistence <-> Infrastructure)

Example 3: Advanced — Full Bounded Context Architecture Review

Section titled “Example 3: Advanced — Full Bounded Context Architecture Review”

Performs a comprehensive architecture review across the entire codebase. Comprehensively analyzes Aggregate boundary redesign, Domain Service extraction candidates, Value Object promotion targets, and event flow consistency.

/domain-review Do a full architecture review from Eric Evans' DDD perspective.
## Full Architecture Review Results
### 1. Per-Layer Violation Summary
| Layer | PASS | WARN | FAIL | Key Issues |
|-------|------|------|------|-----------|
| Domain | 12 | 2 | 0 | 2 Description primitive type issues |
| Application | 8 | 1 | 0 | Credit validation logic leaked into Application |
| Adapter | 6 | 0 | 0 | -- |
### 2. Aggregate Boundary Analysis
| Aggregate | Invariants | Events | Status | Improvement Suggestion |
|-----------|-----------|--------|--------|----------------------|
| Product | 3 (name, price, deletion) | 4 | PASS | -- |
| Order | 4 (line, status, amount, address) | 2 | PASS | -- |
| Customer | 2 (name, email) | 1 | WARN | Recommend promoting CreditLimit to VO |
| Inventory | 2 (quantity, threshold) | 2 | PASS | -- |
### 3. Domain Service Extraction Candidates
| Current Location | Logic | Extraction Target | Reason |
|-----------------|-------|-------------------|--------|
| CreateOrderCommand | Credit limit validation | OrderCreditCheckService | Cross-Aggregate logic |
### 4. Value Object Promotion Candidates
| Current Type | Usage Location | Domain Rule | Suggested VO |
|-------------|---------------|-------------|--------------|
| string Description | Product, Order | Max 500 chars, must not be empty | Description VO |
| decimal CreditLimit | Customer | Positive, comparison operations used | CreditLimit VO |
### 5. Event Flow Consistency
| Aggregate | Command Method | Event Published | Status |
|-----------|---------------|-----------------|--------|
| Product.Create | CreatedEvent | PASS | -- |
| Product.UpdateName | NameUpdatedEvent | PASS | -- |
| Product.Delete | DeletedEvent | PASS | -- |
| Order.Create | CreatedEvent | PASS | -- |
| Order.Confirm | ConfirmedEvent | PASS | -- |
### 6. Overall Assessment
- DDD tactical design principles are well adhered to overall
- Primitive Obsession in 2 cases -- Recommend VO promotion
- Application layer logic leakage in 1 case -- Recommend Domain Service extraction
- Aggregate boundaries and event ownership are consistent

The full review analyzes across 6 axes:

  1. Layer dependency — Is each layer’s dependency direction correct
  2. Aggregate boundaries — Transactional consistency, ID references, invariant scope
  3. Domain Service necessity — Is cross-Aggregate logic in the right place
  4. Value Object utilization — Where Primitive Obsession remains
  5. Event flow — Are events published for all state changes
  6. Functorium pattern compliance — sealed, private constructors, Fin<T> returns

Reviews correct usage of the ApplyT pattern in the Application layer.

ItemReview ContentCorrect Example
Error accumulationAre errors accumulated with Apply when validating multiple VOs(v1, v2).Apply((a, b) => ...)
CreateFromValidatedIs the validation-bypassing factory used inside ApplyProductName.Create(n).ThrowIfFail()
Single fieldIs unnecessary Apply not used when there’s only 1 VOSimple Create + if (IsFail)
ToFin conversionIs the .As().ToFin() chain correctValidation -> Fin conversion
| Item | Status | Violation | Improvement Suggestion |
|------|--------|-----------|----------------------|
| ApplyT error accumulation | WARN | 3 VOs validated sequentially | Apply pattern for parallel validation + error accumulation |
| CreateFromValidated | FAIL | Create re-called inside Apply | Use Create -> ThrowIfFail to bypass validation |

Reviews correct usage of CtxEnricher and Observable Port.

ItemReview Content
CtxPillar appropriatenessAre high-cardinality fields not propagated to MetricsTag
CtxRoot promotionAre key identifiers promoted to ctx.{field} root
ObservableSignalIs ObservableSignal used for internal adapter logging
Observable PortIs [GenerateObservablePort] applied to all Ports
RequestCategoryAre correct categories ("repository", "query", "external_api") used
error.type classificationIs expected/exceptional/aggregate classification correct
## Observability Review Results
| Item | Status | Violation | Improvement Suggestion |
|------|--------|-----------|----------------------|
| CtxPillar | FAIL | customer_id set to CtxPillar.All | Change to CtxPillar.Default (high cardinality) |
| Observable Port | PASS | [GenerateObservablePort] applied to all Repositories | -- |
| RequestCategory | WARN | ExternalApiAdapter RequestCategory missing | Set to "external_api" |