Code Review (Combined)
Overview
Validates implemented code against both DDD and OOP principles. This is the standard post-implementation review.
Announce at start: "Using ddd-workflow:code-review to validate implementation."
What This Reviews
Runs both checklists:
- •DDD review — Domain modeling, bounded contexts, layer purity
- •OOP review — SRP, patterns, conditionals, composition
Quick Combined Checklist
DDD Compliance (from criteria/ddd-checklist.md)
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__
Entities:
- • Identity-based equality
- • Factory methods for creation (
Entity.create(...)) - • State transitions via State pattern (no conditionals)
- • Emits domain events for significant changes
Repositories:
- • Interface defined in domain layer
- • Works with domain models only (not ORM)
- • Implementation in infrastructure layer
OOP Compliance (from criteria/oop-checklist.md)
Conditionals (Zero Tolerance):
- • No
if/elif/elsecontrolling behavior in domain/application - • State Pattern for state-dependent behavior
- • Strategy Pattern for algorithm selection
- • Factory Pattern for type-based creation
Method Design:
- • Single responsibility per method
- • No "and" in method names (unless single business action)
- • Methods fit on one screen (~20 lines)
Composition:
- • Prefer composition over inheritance
- • Inject behavior via protocols/ABCs
- • Dependencies injected, not constructed internally
Red Flags
| Red Flag | Problem | Fix |
|---|---|---|
from sqlalchemy in domain | Infrastructure leak | Protocol in domain, impl in infrastructure |
if in entity method | Conditional smell | State pattern, composed objects |
| Mutable value object | Identity confusion | frozen=True dataclass |
| Service modifies entity | Anemic model | Entity coordinates via composition |
| "and" in method name | Mixed responsibilities | Split into focused methods |
| Boolean flag parameter | Hidden branching | Extract strategies/states |
Review Process
- •Identify files to review - Ask user or detect from recent changes
- •Run DDD checklist - Check each item against the code
- •Run OOP checklist - Check each item against the code
- •Compile findings - Group by severity
- •Present report - With specific file:line references
Output Format
markdown
## Code Review Results ### Critical Issues | File | Line | Issue | Fix | |------|------|-------|-----| | domain/user.py | 45 | Conditional in entity | Use State pattern | ### Suggestions - Consider extracting X to improve testability ### Passed Checks - ✓ Domain layer purity - ✓ Value object immutability - ✓ Repository pattern compliance ### Summary X critical issues, Y suggestions. [Ready for merge / Needs fixes]
When to Use
- •After completing a task from an implementation plan
- •Before creating a PR
- •When refactoring existing code
- •During code review of others' work
Related Skills
- •
ddd-workflow:code-review-ddd— DDD-focused review only - •
ddd-workflow:code-review-oop— OOP-focused review only