domain-driven-design
Domain-Driven Design Skill
DDD manages complexity through alignment between software and business reality. Strategic design (boundaries, language, subdomains) provides more value than tactical patterns (aggregates, repositories).
When to Apply DDD
Apply DDD when:
- Domain has intricate business rules
- System is long-lived and high-value
- Domain experts are available
- Multiple teams/departments involved
- Software represents competitive advantage
DDD is overkill when:
- Simple CRUD applications
- Tight deadlines, limited budgets
- No domain experts available
- Complexity is purely technical, not business
Core Workflow
- Domain Discovery → 2. Bounded Context Definition → 3. Context Mapping → 4. Architecture Selection → 5. Tactical Implementation
See WORKFLOW.md for detailed step-by-step instructions for each phase.
Quick Reference
Subdomain Types (Problem Space)
| Type | Investment | Example |
|---|---|---|
| Core | Maximum - competitive advantage | Recommendation engine, trading logic |
| Supporting | Custom but quality tradeoffs OK | Inventory management |
| Generic | Buy/outsource | Auth, email, payments |
Key Decision: Entity vs Value Object
- Entity: Has identity, tracked through time, mutable →
Customer,Order - Value Object: Defined by attributes, immutable, interchangeable →
Money,Address,Email
Default to value objects. Only use entities when identity matters.
Aggregate Design Rules (Vaughn Vernon)
- Model true invariants in consistency boundaries
- Design small aggregates (~70% should be root + value objects only)
- Reference other aggregates by ID only
- Use eventual consistency outside the boundary
Architecture Decision
Start with modular monolith when:
├── Team < 20 developers
├── Domain boundaries unclear
├── Time-to-market critical
└── Strong consistency required
Consider microservices when:
├── Bounded contexts have distinct languages
├── Teams can own full contexts
├── Independent scaling required
└── DevOps maturity exists
Detailed References
- Strategic Patterns: See references/STRATEGIC-PATTERNS.md for subdomains, bounded contexts, context mapping, event storming
- Tactical Patterns: See references/TACTICAL-PATTERNS.md for entities, value objects, aggregates, services, repositories
- Architecture Alignment: See references/ARCHITECTURE-ALIGNMENT.md for clean/hexagonal architecture, modular monolith, microservices
- Workflow: See WORKFLOW.md for detailed step-by-step DDD implementation process
- Anti-Patterns: See references/ANTI-PATTERNS.md for common pitfalls and how to avoid them
- Examples: See EXAMPLES.md for scenario walkthroughs applying DDD concepts
- Troubleshooting: See TROUBLESHOOTING.md for common issues and solutions
Critical Reminders
- Ubiquitous language first - Code should read like business language
- Strategic before tactical - Understand boundaries before implementing patterns
- Apply tactical patterns selectively - Only in core domains where complexity warrants
- One aggregate per transaction - Cross-aggregate consistency via domain events
- Persistence ignorance - Domain layer has no infrastructure dependencies
Related Skills
| Need | Skill |
|---|---|
| Data layer implementation | spring-boot-data-ddd — JPA/JDBC aggregates, repositories, transactions |
| REST API layer | spring-boot-web-api — Controllers, validation, exception handling |
| Module boundaries | spring-boot-modulith — Module structure, event-driven communication |
| Testing patterns | spring-boot-testing — Aggregate tests, module tests, Scenario API |
| Security for domains | spring-boot-security — Method-level authorization, role-based access |
More from joaquimscosta/arkhe-claude-plugins
skill-validator
Validate skills against Anthropic best practices for frontmatter, structure, content, file organization, hooks, MCP, and security (62 rules in 8 categories). Use when creating new skills, updating existing skills, before publishing skills, reviewing skill quality, or when user mentions "validate skill", "check skill", "skill best practices", "skill review", or "lint skill".
30code-explanation
Explains complex code through clear narratives, visual diagrams, and step-by-step breakdowns. Use when user asks to explain code, understand algorithms, analyze design patterns, wants code walkthroughs, or mentions "explain this code", "how does this work", "code breakdown", or "understand this function".
22generating-changelog
Analyzes git commit history and generates professional changelogs with semantic versioning, conventional commit support, and multiple output formats (Keep a Changelog, Conventional, GitHub). Use when editing CHANGELOG.md, CHANGELOG.txt, or HISTORY.md files, preparing release notes, creating releases, bumping versions, updating changelog, documenting changes, writing release notes, tracking changes, version bump, tag release, or when user mentions "changelog", "release notes", "version history", "release", "semantic versioning", or "conventional commits".
21workflow-orchestration
>
19generating-stitch-screens
>
19flyway-consolidate
Analyze and consolidate Flyway SQL migrations into clean, domain-grouped CREATE TABLE migrations for pre-production projects. Use when consolidating database migrations, refactoring Flyway schemas, simplifying migration history, grouping tables by domain, or when user mentions "consolidate migrations", "merge migrations", "clean up Flyway", "refactor schema", "baseline migrations".
18