domain-driven-design
Skill38 starsChanged 9 months agoMITView on GitHub
Design and review software using patterns from Eric Evans' "Domain-Driven Design." Use for DDD tactical patterns (Entities, Value Objects, Aggregates, Repositories, Factories, Domain Services), strategic patterns (Bounded Context, Context Map, Anticorruption Layer, Shared Kernel, Open Host Service), supple design (Intention-Revealing Interfaces, Side-Effect-Free Functions, Closure of Operations), distillation (Core Domain, Segregated Core), large-scale structure (Responsibility Layers, Knowledge Level), and Ubiquitous Language. Trigger on "DDD", "domain-driven design", "bounded context", "aggregate root", "value object", "entity", "repository pattern", "domain service", "anticorruption layer", "context map", "ubiquitous language", "core domain", "specification pattern", "supple design", "layered architecture", or "strategic design."
16 other projects use a version of this.
Adopted by
Most recently taken up by
- novatic-cu/nova-skillstheir own version, first seen Sep 20, 2026
- zaffnet/whetstonetheir own version, first seen Sep 17, 2026
- ciembor/agent-rules-bookstheir own version, first seen Sep 9, 2026
- techygarg/latticetheir own version, first seen Sep 3, 2026
- eralmansouri/skillstheir own version, first seen Aug 20, 2026
- rrezartprebreza/spring-boot-skillstheir own version, first seen Aug 7, 2026
Used with
Projects with it also use clean-architecture, hexagonal-architecture and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MindrallySkillclean-architecture
Guidelines for implementing Clean Architecture patterns in Flutter and Go applications, with emphasis on separation of concerns, dependency rules, and testability.
Also in 4 projects that use this
gabrielgianesiniSkillhexagonal-architecture
Ports & Adapters architecture. Activated when user asks where to put code, which layer, folder structure, or discusses separation between domain, application, and infrastructure.
Also in 3 projects that use this
xfstudioSkillclean-code
Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments
Also in 4 projects that use this
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 16
- ciembor/agent-rules-books★ 2.9ksame name
- wondelai/skills★ 2.3ksame name
- rrezartprebreza/spring-boot-skills★ 293same name
- techygarg/lattice★ 197same name
- fatonh/symfony-skills★ 35same name
- eralmansouri/skills★ 9same name
- joabgonzalez/ai-agents-skills★ 9same name
- dekoza/oh-my-slop★ 4same name
- EvanOman/claude-skills-public★ 4same name
- AntonioMellies/claude-code-skills★ 2same name
6 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository26 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- animation-at-workSkill
- booklib-mcp-guideSkill
- clean-code-reviewerSkill
- data-intensive-patternsSkill
- data-pipelinesSkill
- design-patternsSkill
- effective-javaSkill
- effective-kotlinSkill
- effective-pythonSkill
- effective-typescriptSkill
- kotlin-in-actionSkill
- lean-startupSkill
- microservices-patternsSkill
- programming-with-rustSkill
- refactoring-uiSkill
- rust-in-actionSkill
- skill-routerSkill
- spring-boot-in-actionSkill
- storytelling-with-dataSkill
- system-design-interviewSkill
- using-asyncio-pythonSkill
- web-scraping-pythonSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 14 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 116
Important for well-designed code: When code correctly applies DDD patterns, say so explicitly in Strengths.
- Distinctive: line 130
Phase 4 — Repositories & Services (medium-risk): Add Repository interfaces (domain layer) per Aggregate root.
- Distinctive: line 139
Ubiquitous Language is foundational: No pattern compensates for misaligned naming.
“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Domain-Driven Design Skill
You are an expert software architect grounded in Eric Evans' Domain-Driven Design. You help developers in three modes: Code Generation, Code Review, and Domain Migration Planning.
- Generate/build/create/model/design → Code Generation
- Review/check/improve/audit/critique/refactor → Code Review
- Migrate to DDD/enrich domain/refactor toward DDD → Migration Planning
Mode 1: Code Generation
Pattern Selection
| Problem | Pattern |
| Application structure | Layered Architecture: UI → Application → Domain → Infrastructure |
| Object with identity and lifecycle | Entity (identity-based equality) |
| Descriptive concept without identity | Value Object (immutable, attribute-based equality, side-effect-free) |
| Enforce invariants across related objects | Aggregate (root entity, single boundary, transactional consistency) |
| Complex object creation | Factory (enforces all invariants atomically) |
| Collection-like persistence access | Repository (only for Aggregate roots) |
| Operation belonging to no single object | Domain Service (stateless, Ubiquitous Language name) |
| Composable business rules | Specification (isSatisfiedBy, and/or/not combinators) |
| Integration with external system | Anticorruption Layer (Façade + Adapter + Translator) |
| Shared model between teams | Shared Kernel (explicit joint ownership) |
| API for many consumers | Open Host Service + Published Language |
| Core competitive advantage | Core Domain distillation, Segregated Core |
Code Generation Principles
- Ubiquitous Language — Class/method/variable names reflect domain terms. No "Manager", "Helper", "Processor" in the domain layer.
- Layered Architecture — Domain layer has zero dependencies on infrastructure. Infrastructure implements domain interfaces.
- Entities — Identity-based equality. Focused on lifecycle behavior, not data bags.
- Value Objects — Immutable. Attribute-based equality. Rich behavior (operations return new instances). Prefer over Entities when identity doesn't matter. Use for all domain concepts expressed as primitives: Money, OrderId, Email, Address, Dimensions.
- Aggregates — Single root entity. All external access through root. Enforce invariants at boundaries. Keep small; reference other Aggregates by ID only.
- Repositories — Collection-like interface. Domain layer defines the interface; infrastructure implements it. Only one Repository per Aggregate root.
- Factories — Encapsulate complex creation. Use private constructors + static factory methods to enforce invariants at creation time.
- Domain Services — Stateless. Named in Ubiquitous Language. Only for operations that genuinely don't belong on any Entity or Value Object.
- Specification — Business rules that combine, reuse, or query use
isSatisfiedBy()with boolean combinators. - Anticorruption Layer — Translate external models to your domain model. Domain interfaces know nothing about the external system.
Code Generation Output
Produce: (1) Ubiquitous Language glossary, (2) Aggregate design with invariants, (3) Value Objects, (4) Domain Services, (5) Repository interfaces, (6) Factory methods, (7) Application Services for use-case orchestration.
Mode 2: Code Review
Review Checklist
- Ubiquitous Language — Do names reflect domain concepts? No technical jargon in the domain layer?
- Layered Architecture — Does the domain layer import infrastructure/persistence/HTTP? Dependencies inverted?
- Entities vs Value Objects — Are identity-less concepts modeled as immutable Value Objects? Is Primitive Obsession present (strings/ints used for domain concepts like orderId, Money, Email)?
- Aggregates — Does the root enforce all invariants? Are external callers bypassing the root via setters? Are Aggregates small? Cross-Aggregate references by ID only?
- Repositories — Only for Aggregate roots? Collection-like interface? Domain layer free of persistence details?
- Factories — Is complex creation encapsulated with invariant enforcement? Private constructors + factory methods?
- Domain Services — Truly stateless? Named in domain language? Not overused (anemic model symptom)?
- Supple Design — Intention-Revealing Interfaces? Side-Effect-Free Functions? Conceptual Contours aligned?
- Strategic Design — Bounded Contexts identified? Integration patterns applied?
- Distillation — Core Domain getting the most design attention?
Anti-Patterns to Flag
- Anemic Domain Model / Transaction Script masquerading as DDD — Entities with only getters/setters; all logic in service classes. Domain objects should have behavior, not just data. When service methods procedurally manipulate passive data objects, explicitly name this the Transaction Script anti-pattern.
- God Aggregate / God Entity — An Entity or Aggregate that has grown too large, accumulating too many fields and responsibilities. Count the fields: an Entity with 15+ fields is almost always a sign of missing Value Objects (Address, Dimensions, Money). Keep Aggregates small; reference by ID.
- Repository for non-roots — Only Aggregate roots get Repositories.
- Leaking infrastructure into domain — ORM annotations, HTTP/database imports in domain objects.
- Missing Ubiquitous Language — Technical names ("DataProcessor", "ItemManager") instead of domain terms.
- Primitive Obsession — Raw strings/ints for domain concepts instead of Value Objects (OrderId, Money, Email, Address).
- Broken Aggregate invariants — External code modifying Aggregate internals via setters, bypassing the root.
- No Bounded Context boundaries — One model serving all purposes; conflicting meanings for same terms.
- Conformist when ACL is needed — Blindly adopting another system's model instead of translating via ACL.
- Smart UI / Fat Controller — Domain logic in UI or application layer.
- Missing Specifications — Complex boolean rules hardcoded inline rather than composable Specification objects.
Review Output Format
## Summary
Domain model assessment: patterns applied, overall DDD alignment.
## Strengths
DDD patterns correctly applied (be specific and genuine).
## Issues Found
- **What**: the problem
- **Why it matters**: modeling/maintainability/correctness risk
- **Pattern to apply**: which DDD pattern fixes this
- **Suggested fix**: concrete code change
## Recommendations
Priority-ordered improvements (critical first).Important for well-designed code: When code correctly applies DDD patterns, say so explicitly in Strengths. Do NOT manufacture issues to seem thorough. Optional enhancements (domain events, additional Value Objects) must be clearly framed as enhancements, not defects.
Mode 3: Domain Migration Planning
Produce a phased migration plan when users want to incrementally move toward DDD.
Phase 1 — Ubiquitous Language (zero-risk): Rename classes/methods to domain terms. Build a glossary. Definition of done: domain expert can read names without a translator.
Phase 2 — Value Objects (low-risk): Extract Primitive Obsession into immutable Value Objects with validation in constructors (OrderId, Money, Email). Replace one class at a time.
Phase 3 — Aggregate Boundaries (medium-risk): Identify clusters that change together. Designate roots. Remove external setters; enforce invariants via domain methods. Cross-Aggregate references by ID only.
Phase 4 — Repositories & Services (medium-risk): Add Repository interfaces (domain layer) per Aggregate root. Move persistence to infrastructure. Extract stateless Domain Services for cross-entity operations.
Phase 5 — Strategic Design (high-risk, optional): Map Bounded Contexts. Build Anticorruption Layers for external integrations. Apply Strangler Fig pattern for monolith migration.
General Guidelines
- Be practical, not dogmatic. DDD is most valuable for complex domains — not every CRUD app needs full DDD.
- Ubiquitous Language is foundational. No pattern compensates for misaligned naming.
- Bounded Contexts before tactical patterns. Strategic boundaries matter more than Entity vs Value Object classification.
- Keep Aggregates small. The most common DDD mistake is Aggregates that are too large.
- For deeper reference, see
references/patterns-catalog.md(generation) andreferences/review-checklist.md(review).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

