askill
code-review-ddd

code-review-dddSafety 100Repository

DDD-focused code review. Validates domain layer purity, entity/VO usage, repository patterns, and bounded contexts. Pairs with code-review-oop for complete review.

0 stars
1.2k downloads
Updated 2/6/2026

Package Files

Loading files...
SKILL.md

DDD Code Review

Overview

Validates code against Domain-Driven Design principles. Use alongside ddd-workflow:code-review-oop for complete review:

  • code-review-oop: SRP, composition, design patterns, dependency injection
  • code-review-ddd: Domain modeling, bounded contexts, tactical patterns

Core principle: Domain layer expresses business concepts in pure Python. Infrastructure concerns stay out. Conditionals in entity methods are a smell — push to composed objects.

Quick DDD Compliance Check

Layered Architecture

  • Domain layer has zero external imports (no SQLAlchemy, requests, etc.)
  • Application layer orchestrates; no business logic
  • Infrastructure implements domain interfaces
  • Dependencies point inward: infrastructure → application → domain

Value Objects

  • Immutable (@dataclass(frozen=True))
  • Equality by value, not identity
  • Validation in __post_init__
  • No side effects

Entities

  • Identity-based equality
  • Factory methods for creation (Entity.create(...))
  • State transitions via State pattern (no conditionals)
  • Emits domain events for significant changes

Aggregates

  • Single entry point (aggregate root)
  • Protects invariants
  • Transactional consistency boundary
  • External references by ID only

Domain Events

  • Past tense naming (OrderPlaced, not PlaceOrder)
  • Immutable (frozen dataclass)
  • Contains all data handlers need
  • Emitted by entities, not services

Repositories

  • Interface defined in domain layer
  • Works with domain models only (not ORM)
  • Implementation in infrastructure layer
  • Specific query methods (not generic search())

Bounded Contexts

  • Clear boundaries between contexts
  • Shared kernel for cross-context models
  • Anti-corruption layer for external systems

Ubiquitous Language

  • Code uses domain terminology
  • No technical jargon in domain layer
  • Names match domain expert vocabulary

Red Flags

Red FlagProblemFix
from sqlalchemy in domainInfrastructure leakProtocol in domain, impl in infrastructure
Mutable value objectIdentity confusionfrozen=True dataclass
if in entity methodConditional smellState pattern, composed objects
Service modifies entityAnemic modelEntity coordinates via composition
repository.search(**kwargs)Generic querySpecific query methods
Aggregate exposes mutable listBroken invariantsReturn immutable views
Event created in serviceSplit behaviorEntity emits events
Import from other contextTight couplingACL or shared kernel
process, handle, do namesUnclear meaningUbiquitous language

Quick Self-Review Questions

  1. Dependency Direction: Does domain import from infrastructure? → Move interface to domain
  2. Value Object: Same values = equal? → Make immutable, value-based equality
  3. Entity Behavior: Conditionals in entity? → Push to State pattern
  4. Aggregate Invariant: Can external code break it? → Encapsulate
  5. Domain Event: Past tense with all needed data? → Rename, include data
  6. Repository: Exposes ORM or generic queries? → Domain models, specific methods
  7. Bounded Context: Direct imports from other context? → Add ACL
  8. Language: Would domain expert understand? → Use ubiquitous language

Integration with code-review-oop

ConcernSkill
Single Responsibilitycode-review-oop
Dependency Injectioncode-review-oop
State/Strategy Patternscode-review-oop
Eliminating Conditionalscode-review-oop
Domain Layer Puritycode-review-ddd
Value Objects & Entitiescode-review-ddd
Aggregates & Eventscode-review-ddd
Bounded Contextscode-review-ddd

References (load on demand)

  • Detailed violation/fix examples: references/violations-and-fixes.md
  • REST API architecture guide: references/rest-api-guide.md

When to Skip

  • CRUD-only code with no business logic
  • Scripts or utilities
  • Prototypes not going to production
  • Pure infrastructure code

For domain model code: Use this checklist.

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

90/100Analyzed 2/19/2026

Highly comprehensive DDD code review skill with detailed checklists, red flags table, and clear integration guidance. Well-structured with when-to-use guidance, self-review questions, and references. Slightly generic tags that don't fully reflect the DDD focus.

100
85
90
95
95

Metadata

Licenseunknown
Version-
Updated2/6/2026
Publishertzenderman

Tags

apigithub-actions