@lenardangeloolajay/len-toolkit 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +209 -0
- package/bin/cli.js +244 -0
- package/package.json +35 -0
- package/src/installer.js +236 -0
- package/templates/configs/.editorconfig +12 -0
- package/templates/configs/sample.gitignore +8 -0
- package/templates/docs/FEATURE.md +40 -0
- package/templates/docs/HANDOFF.md +39 -0
- package/templates/docs/IMPLEMENTATION_PLAN.md +47 -0
- package/templates/docs/SPEC_INDEX.md +12 -0
- package/templates/docs/VERIFICATION.md +14 -0
- package/templates/docs/product/ARCHITECTURE.md +22 -0
- package/templates/docs/product/CONSTRAINTS.md +22 -0
- package/templates/docs/product/DATA_MODEL.md +22 -0
- package/templates/docs/product/OVERVIEW.md +22 -0
- package/templates/examples/flutter-handoff/EXERCISES.md +16 -0
- package/templates/examples/flutter-handoff/HANDOFF.md +32 -0
- package/templates/examples/flutter-handoff/docs/SPEC_INDEX.md +19 -0
- package/templates/examples/flutter-handoff/docs/evidence/FEAT-001-verification.md +14 -0
- package/templates/examples/flutter-handoff/docs/features/FEAT-001-local-note.md +40 -0
- package/templates/examples/flutter-handoff/docs/plans/FEAT-001-implementation.md +43 -0
- package/templates/examples/flutter-handoff/docs/product/ARCHITECTURE.md +24 -0
- package/templates/examples/flutter-handoff/docs/product/CONSTRAINTS.md +13 -0
- package/templates/examples/flutter-handoff/docs/product/DATA_MODEL.md +20 -0
- package/templates/examples/flutter-handoff/docs/product/OVERVIEW.md +26 -0
- package/templates/rules/.cursorrules +7 -0
- package/templates/rules/AGENTS.md +61 -0
- package/templates/rules/GEMINI.md +7 -0
- package/templates/skills/a-philosophy-of-software-design/SKILL.md +11 -0
- package/templates/skills/a-philosophy-of-software-design/a-philosophy-of-software-design.md +370 -0
- package/templates/skills/a-philosophy-of-software-design/a-philosophy-of-software-design.mini.md +46 -0
- package/templates/skills/a-philosophy-of-software-design/a-philosophy-of-software-design.nano.md +35 -0
- package/templates/skills/clean-architecture/SKILL.md +11 -0
- package/templates/skills/clean-architecture/clean-architecture.md +515 -0
- package/templates/skills/clean-architecture/clean-architecture.mini.md +49 -0
- package/templates/skills/clean-architecture/clean-architecture.nano.md +36 -0
- package/templates/skills/clean-code/SKILL.md +11 -0
- package/templates/skills/clean-code/clean-code.md +297 -0
- package/templates/skills/clean-code/clean-code.mini.md +47 -0
- package/templates/skills/clean-code/clean-code.nano.md +32 -0
- package/templates/skills/code-complete/SKILL.md +11 -0
- package/templates/skills/code-complete/code-complete.md +354 -0
- package/templates/skills/code-complete/code-complete.mini.md +56 -0
- package/templates/skills/code-complete/code-complete.nano.md +41 -0
- package/templates/skills/council/SKILL.md +37 -0
- package/templates/skills/designing-data-intensive-applications/SKILL.md +11 -0
- package/templates/skills/designing-data-intensive-applications/designing-data-intensive-applications.md +393 -0
- package/templates/skills/designing-data-intensive-applications/designing-data-intensive-applications.mini.md +55 -0
- package/templates/skills/designing-data-intensive-applications/designing-data-intensive-applications.nano.md +34 -0
- package/templates/skills/domain-driven-design/SKILL.md +11 -0
- package/templates/skills/domain-driven-design/domain-driven-design.md +979 -0
- package/templates/skills/domain-driven-design/domain-driven-design.mini.md +48 -0
- package/templates/skills/domain-driven-design/domain-driven-design.nano.md +39 -0
- package/templates/skills/domain-driven-design-distilled/SKILL.md +11 -0
- package/templates/skills/domain-driven-design-distilled/domain-driven-design-distilled.md +317 -0
- package/templates/skills/domain-driven-design-distilled/domain-driven-design-distilled.mini.md +56 -0
- package/templates/skills/domain-driven-design-distilled/domain-driven-design-distilled.nano.md +41 -0
- package/templates/skills/implementation-plan/SKILL.md +42 -0
- package/templates/skills/implementing-domain-driven-design/SKILL.md +11 -0
- package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.md +337 -0
- package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.mini.md +57 -0
- package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.nano.md +37 -0
- package/templates/skills/patterns-of-enterprise-application-architecture/SKILL.md +11 -0
- package/templates/skills/patterns-of-enterprise-application-architecture/patterns-of-enterprise-application-architecture.md +404 -0
- package/templates/skills/patterns-of-enterprise-application-architecture/patterns-of-enterprise-application-architecture.mini.md +54 -0
- package/templates/skills/patterns-of-enterprise-application-architecture/patterns-of-enterprise-application-architecture.nano.md +35 -0
- package/templates/skills/ponytail/SKILL.md +124 -0
- package/templates/skills/ponytail-audit/SKILL.md +45 -0
- package/templates/skills/ponytail-debt/SKILL.md +48 -0
- package/templates/skills/ponytail-gain/SKILL.md +17 -0
- package/templates/skills/ponytail-help/SKILL.md +42 -0
- package/templates/skills/ponytail-review/SKILL.md +61 -0
- package/templates/skills/refactoring/SKILL.md +11 -0
- package/templates/skills/refactoring/refactoring.md +433 -0
- package/templates/skills/refactoring/refactoring.mini.md +49 -0
- package/templates/skills/refactoring/refactoring.nano.md +37 -0
- package/templates/skills/refactoring-guru/SKILL.md +11 -0
- package/templates/skills/refactoring-guru/refactoring-guru.md +765 -0
- package/templates/skills/refactoring-guru/refactoring-guru.mini.md +64 -0
- package/templates/skills/refactoring-guru/refactoring-guru.nano.md +41 -0
- package/templates/skills/release-it/SKILL.md +11 -0
- package/templates/skills/release-it/release-it.md +382 -0
- package/templates/skills/release-it/release-it.mini.md +48 -0
- package/templates/skills/release-it/release-it.nano.md +38 -0
- package/templates/skills/security-audit/AI-AND-LLM.md +83 -0
- package/templates/skills/security-audit/ATTACK-CLASSES.md +130 -0
- package/templates/skills/security-audit/CLIENT-SIDE.md +83 -0
- package/templates/skills/security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
- package/templates/skills/security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
- package/templates/skills/security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
- package/templates/skills/security-audit/HUNTING.md +251 -0
- package/templates/skills/security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
- package/templates/skills/security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
- package/templates/skills/security-audit/RECONNAISSANCE.md +156 -0
- package/templates/skills/security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
- package/templates/skills/security-audit/SKILL.md +192 -0
- package/templates/skills/security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
- package/templates/skills/security-audit/VALIDATION-AND-REPORTING.md +186 -0
- package/templates/skills/security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
- package/templates/skills/security-audit/report-schema.json +461 -0
- package/templates/skills/security-audit/validate-coverage-ledger.cjs +872 -0
- package/templates/skills/security-audit/validate-coverage-ledger.test.cjs +740 -0
- package/templates/skills/security-audit/validate-findings.cjs +773 -0
- package/templates/skills/security-audit/validate-findings.test.cjs +652 -0
- package/templates/skills/spec/SKILL.md +55 -0
- package/templates/skills/the-pragmatic-programmer/SKILL.md +11 -0
- package/templates/skills/the-pragmatic-programmer/the-pragmatic-programmer.md +359 -0
- package/templates/skills/the-pragmatic-programmer/the-pragmatic-programmer.mini.md +65 -0
- package/templates/skills/the-pragmatic-programmer/the-pragmatic-programmer.nano.md +44 -0
- package/templates/skills/working-effectively-with-legacy-code/SKILL.md +11 -0
- package/templates/skills/working-effectively-with-legacy-code/working-effectively-with-legacy-code.md +371 -0
- package/templates/skills/working-effectively-with-legacy-code/working-effectively-with-legacy-code.mini.md +50 -0
- package/templates/skills/working-effectively-with-legacy-code/working-effectively-with-legacy-code.nano.md +35 -0
package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.md
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
# OBEY Implementing Domain-Driven Design by Vaughn Vernon
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This repository follows **Implementing Domain-Driven Design** in the practical style of Vaughn Vernon:
|
|
6
|
+
apply DDD operationally, with explicit bounded contexts, disciplined aggregates, and implementation patterns that survive real systems.
|
|
7
|
+
|
|
8
|
+
All code generation, edits, and reviews must optimize for:
|
|
9
|
+
- explicit bounded contexts
|
|
10
|
+
- local ubiquitous language
|
|
11
|
+
- small aggregate boundaries
|
|
12
|
+
- identities over object graph coupling
|
|
13
|
+
- eventual consistency where appropriate
|
|
14
|
+
- context mapping instead of shared muddled models
|
|
15
|
+
- practical DDD implementation instead of theory theater
|
|
16
|
+
|
|
17
|
+
This file is a binding engineering policy: `MUST` is binding, `SHOULD` is a strong default, and `MUST NOT` is forbidden.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Primary Directive
|
|
22
|
+
|
|
23
|
+
Model the domain in a way that can actually be implemented and evolved.
|
|
24
|
+
|
|
25
|
+
When uncertain:
|
|
26
|
+
1. identify the bounded context
|
|
27
|
+
2. use the local ubiquitous language
|
|
28
|
+
3. define the aggregate consistency boundary conservatively
|
|
29
|
+
4. reference other aggregates by identity
|
|
30
|
+
5. keep infrastructure outside the model
|
|
31
|
+
6. integrate across contexts through explicit translation
|
|
32
|
+
|
|
33
|
+
Reject designs that sound like DDD but behave like generic CRUD plus renamed classes.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Strategic Design Rules
|
|
38
|
+
|
|
39
|
+
### Bounded Context Is Mandatory
|
|
40
|
+
1. Every substantial domain area must belong to a named bounded context.
|
|
41
|
+
2. A model is valid only inside its bounded context.
|
|
42
|
+
3. Terms may change meaning across contexts; that is normal and must be respected.
|
|
43
|
+
4. Do not share model classes across contexts by default.
|
|
44
|
+
|
|
45
|
+
### Context Mapping Is a Design Artifact
|
|
46
|
+
1. Every context interaction must have an explicit relationship.
|
|
47
|
+
2. Translation responsibility must be visible.
|
|
48
|
+
3. Upstream/downstream influence matters.
|
|
49
|
+
4. External models, partner systems, and legacy systems must not define the local model.
|
|
50
|
+
|
|
51
|
+
### Core Domain Protection
|
|
52
|
+
1. Protect the core domain from generic abstractions and vendor terms.
|
|
53
|
+
2. Spend the richest modeling effort where competitive or operational complexity truly lives.
|
|
54
|
+
3. Keep supporting subdomains simpler.
|
|
55
|
+
|
|
56
|
+
Anti-patterns (MUST NOT):
|
|
57
|
+
- one global company model
|
|
58
|
+
- shared domain package crossing all contexts
|
|
59
|
+
- context boundaries existing only in diagrams but not in code
|
|
60
|
+
- context integration via direct imports of each other's domain classes
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Ubiquitous Language Rules
|
|
65
|
+
|
|
66
|
+
1. Use business terms exactly as they are understood in the current bounded context.
|
|
67
|
+
2. One concept gets one term inside the context.
|
|
68
|
+
3. One term must not carry multiple meanings inside the same context.
|
|
69
|
+
4. Rename code when understanding improves.
|
|
70
|
+
5. Tests, events, commands, repositories, and application services must all speak the same language.
|
|
71
|
+
|
|
72
|
+
Required behavior:
|
|
73
|
+
- use local domain terms in class, method, event, and package names
|
|
74
|
+
- remove technical placeholders when a real domain term exists
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Aggregate Rules of Thumb
|
|
79
|
+
|
|
80
|
+
### Aggregates Are Consistency Boundaries
|
|
81
|
+
1. Design aggregates around invariants that must hold immediately.
|
|
82
|
+
2. Keep aggregates as small as possible.
|
|
83
|
+
3. Small aggregates scale better in both understanding and throughput.
|
|
84
|
+
4. Large object graphs are not evidence of good modeling.
|
|
85
|
+
|
|
86
|
+
### Aggregate Root Discipline
|
|
87
|
+
1. Only the aggregate root may be referenced directly from outside.
|
|
88
|
+
2. All invariant-changing operations must go through the root.
|
|
89
|
+
3. Internal members must not be mutated directly by external code.
|
|
90
|
+
4. Expose intention-revealing behavior, not arbitrary setters.
|
|
91
|
+
|
|
92
|
+
### Reference Other Aggregates by Identity
|
|
93
|
+
1. Prefer IDs over direct object references across aggregate boundaries.
|
|
94
|
+
2. Avoid loading large connected graphs by default.
|
|
95
|
+
3. Cross-aggregate coordination should usually be eventual, not transactional.
|
|
96
|
+
|
|
97
|
+
### One Aggregate per Transaction by Default
|
|
98
|
+
1. Modify one aggregate in one transaction unless there is a compelling reason not to.
|
|
99
|
+
2. Do not stretch transactions across many aggregates out of convenience.
|
|
100
|
+
3. Use events, policies, or process coordination when consistency can be eventual.
|
|
101
|
+
|
|
102
|
+
Anti-patterns (MUST NOT):
|
|
103
|
+
- aggregates sized to fit ORM navigation
|
|
104
|
+
- transactions updating many aggregates by default
|
|
105
|
+
- aggregate roots exposing mutable child collections
|
|
106
|
+
- direct cross-aggregate navigation baked into the model
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Entity and Value Object Rules
|
|
111
|
+
|
|
112
|
+
### Entities
|
|
113
|
+
1. Use entities where identity and lifecycle matter.
|
|
114
|
+
2. Entities must protect meaningful state transitions.
|
|
115
|
+
3. Entity methods must express domain behavior, not generic state changes.
|
|
116
|
+
4. Entities must not be passive ORM containers in behavior-rich domains.
|
|
117
|
+
|
|
118
|
+
### Value Objects
|
|
119
|
+
1. Use value objects aggressively where primitives hide meaning.
|
|
120
|
+
2. Value objects must be immutable by default.
|
|
121
|
+
3. Validation belongs in value object construction.
|
|
122
|
+
4. Equality is by value, not identity.
|
|
123
|
+
|
|
124
|
+
Required behavior:
|
|
125
|
+
- model local value concepts explicitly instead of passing raw primitives for meaningful identifiers, quantities, ranges, names, or descriptive whole values
|
|
126
|
+
- keep invariant enforcement near the concept itself
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Domain and Transformation Service Rules
|
|
131
|
+
|
|
132
|
+
1. Use a domain service for a domain-significant operation that requires multiple domain objects and fits no single entity or value object.
|
|
133
|
+
2. Name domain services in the ubiquitous language.
|
|
134
|
+
3. Use transformation services when domain information must be transformed without assigning behavior to the wrong object.
|
|
135
|
+
4. Keep technical transformation, serialization, transport, and persistence mapping outside the domain model.
|
|
136
|
+
|
|
137
|
+
Anti-patterns (MUST NOT):
|
|
138
|
+
- moving behavior into services to avoid modeling entities or value objects
|
|
139
|
+
- hiding technical mapping behind a domain-sounding service name
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Repository Rules
|
|
144
|
+
|
|
145
|
+
1. Repositories exist for aggregate roots.
|
|
146
|
+
2. Repository interfaces must be defined by the domain or application code that needs them.
|
|
147
|
+
3. Repositories reconstitute and persist aggregates.
|
|
148
|
+
4. Repository APIs should reflect aggregate access needs, not generic table CRUD.
|
|
149
|
+
5. Repositories must return domain objects or domain-oriented results, not ORM rows.
|
|
150
|
+
|
|
151
|
+
Anti-patterns (MUST NOT):
|
|
152
|
+
- giant generic repository abstractions
|
|
153
|
+
- repository per table without aggregate thinking
|
|
154
|
+
- business rules inside repository implementations
|
|
155
|
+
- repositories returning persistence-layer entities into the domain
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Domain Event Rules
|
|
160
|
+
|
|
161
|
+
1. Publish domain events for meaningful business facts.
|
|
162
|
+
2. Event names must be in the past tense.
|
|
163
|
+
3. Domain events are part of the model, not transport mechanics.
|
|
164
|
+
4. Use events to coordinate across aggregates or contexts when immediate consistency is not required.
|
|
165
|
+
5. Keep event payloads meaningful and local to the model.
|
|
166
|
+
|
|
167
|
+
### Event Sourcing
|
|
168
|
+
1. Use event sourcing only when storing the sequence of domain events is the right persistence model for the aggregate.
|
|
169
|
+
2. Keep event streams consistent with aggregate identity and versioning.
|
|
170
|
+
3. Rebuild state from events deterministically.
|
|
171
|
+
4. Version events and upcasters or translators when event meaning evolves.
|
|
172
|
+
5. Do not choose event sourcing just because domain events exist.
|
|
173
|
+
|
|
174
|
+
Anti-patterns (MUST NOT):
|
|
175
|
+
- using events for every property change
|
|
176
|
+
- event names that describe commands instead of facts
|
|
177
|
+
- domain events carrying framework request objects or persistence artifacts
|
|
178
|
+
- using events to compensate for missing aggregate design
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Application Service Rules
|
|
183
|
+
|
|
184
|
+
1. Application services coordinate use cases.
|
|
185
|
+
2. They load aggregates, invoke domain behavior, persist results, and publish resulting events.
|
|
186
|
+
3. Application services must not contain the domain model's core decision logic.
|
|
187
|
+
4. Application services must be thin enough that the model still matters.
|
|
188
|
+
5. Application services may own transaction boundaries and integration coordination.
|
|
189
|
+
|
|
190
|
+
Anti-patterns (MUST NOT):
|
|
191
|
+
- application services containing all branching business rules
|
|
192
|
+
- controllers duplicating application service orchestration
|
|
193
|
+
- repositories and application services both implementing the same invariants
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Module and Package Rules
|
|
198
|
+
|
|
199
|
+
1. Packages/modules must reflect bounded contexts first.
|
|
200
|
+
2. Within a context, organize around domain and use-case ownership, not only technical layers.
|
|
201
|
+
3. Avoid a giant `shared` or `common` package for domain concepts.
|
|
202
|
+
4. Keep the model visible in the structure.
|
|
203
|
+
|
|
204
|
+
Preferred structure examples:
|
|
205
|
+
- `identity/domain`
|
|
206
|
+
- `identity/application`
|
|
207
|
+
- `identity/infrastructure`
|
|
208
|
+
- `identity/interfaces`
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Context Integration Rules
|
|
213
|
+
|
|
214
|
+
### Anticorruption Layer
|
|
215
|
+
Use when integrating with legacy systems or foreign models.
|
|
216
|
+
|
|
217
|
+
Rules (MUST unless marked SHOULD or MUST NOT):
|
|
218
|
+
1. Translate foreign language into the local context's language.
|
|
219
|
+
2. Keep foreign schemas and statuses out of local domain objects.
|
|
220
|
+
3. Own the translation explicitly.
|
|
221
|
+
|
|
222
|
+
### Identity Across Contexts
|
|
223
|
+
1. Use explicit identifiers and integration messages.
|
|
224
|
+
2. Do not pass local aggregates directly across context boundaries.
|
|
225
|
+
3. Keep contract models separate from local models.
|
|
226
|
+
|
|
227
|
+
Anti-patterns (MUST NOT):
|
|
228
|
+
- importing another context's domain package
|
|
229
|
+
- shared enums across contexts with different semantics
|
|
230
|
+
- direct DB coupling between contexts
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Client Representation and Scope Discipline
|
|
235
|
+
|
|
236
|
+
1. Use DTOs, projections, use-case queries, rendition adapters, or mediators when client needs differ from aggregate shape.
|
|
237
|
+
2. Expose REST resources as application-facing representations rather than aggregate internals.
|
|
238
|
+
3. Tailor representations for different clients without changing the domain model for each client.
|
|
239
|
+
4. Compose multiple bounded contexts at the application or integration layer, not by merging their models.
|
|
240
|
+
5. Keep command behavior separate from query models when consistency, performance, or representation needs justify the split.
|
|
241
|
+
6. Keep scope identifiers explicit where context or ownership affects invariants or access.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Practical Simplicity Rule
|
|
246
|
+
|
|
247
|
+
1. Not every subdomain needs full-blown DDD ceremony.
|
|
248
|
+
2. Use richer modeling where complexity is real.
|
|
249
|
+
3. Use simpler patterns in supporting areas.
|
|
250
|
+
4. However, once invariants and lifecycle complexity appear, model them honestly.
|
|
251
|
+
|
|
252
|
+
Anti-patterns (MUST NOT):
|
|
253
|
+
- using DDD vocabulary without changing design
|
|
254
|
+
- over-modeling trivial CRUD subdomains
|
|
255
|
+
- refusing to model real complexity because “simple services are enough”
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Code Generation Rules
|
|
260
|
+
|
|
261
|
+
When generating code, follow this order:
|
|
262
|
+
1. identify the bounded context
|
|
263
|
+
2. state the ubiquitous language term(s)
|
|
264
|
+
3. determine whether the concept is entity, value object, aggregate root, domain event, repository, or application service
|
|
265
|
+
4. define aggregate boundary conservatively
|
|
266
|
+
5. reference other aggregates by ID
|
|
267
|
+
6. place invariants on the aggregate root or local model
|
|
268
|
+
7. define repositories around aggregate access
|
|
269
|
+
8. define application services around use cases
|
|
270
|
+
9. define translation layers for context or infrastructure boundaries
|
|
271
|
+
|
|
272
|
+
Avoid by default:
|
|
273
|
+
- direct cross-context model reuse
|
|
274
|
+
- ORM-shaped aggregates
|
|
275
|
+
- all-powerful application services
|
|
276
|
+
- generic repositories
|
|
277
|
+
- one transaction touching many aggregates
|
|
278
|
+
- shared domain packages across contexts
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Review Rules
|
|
283
|
+
|
|
284
|
+
When reviewing or modifying code, actively look for:
|
|
285
|
+
- missing bounded context ownership
|
|
286
|
+
- context bleeding
|
|
287
|
+
- shared models across different contexts
|
|
288
|
+
- foreign vocabularies polluting the local context
|
|
289
|
+
- oversized aggregates
|
|
290
|
+
- aggregate roots not protecting invariants
|
|
291
|
+
- external code mutating aggregate internals
|
|
292
|
+
- cross-aggregate references by object instead of identity
|
|
293
|
+
- events that are really commands
|
|
294
|
+
- repository contracts shaped like table CRUD
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Testing Rules
|
|
299
|
+
|
|
300
|
+
1. Test aggregate invariants directly.
|
|
301
|
+
2. Test valid and invalid state transitions.
|
|
302
|
+
3. Test value object validation and behavior.
|
|
303
|
+
4. Test domain events as outcomes of domain behavior.
|
|
304
|
+
5. Test repositories as infrastructure separately from aggregate rules.
|
|
305
|
+
6. Test anticorruption and translation layers explicitly.
|
|
306
|
+
7. Test application services for orchestration, not for all domain decisions.
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## Review Checklist
|
|
311
|
+
|
|
312
|
+
Before finalizing any change, verify:
|
|
313
|
+
- Is the bounded context explicit?
|
|
314
|
+
- Is the local ubiquitous language used consistently?
|
|
315
|
+
- Are aggregates small and centered on immediate invariants?
|
|
316
|
+
- Are cross-aggregate references by identity?
|
|
317
|
+
- Does one transaction usually modify one aggregate?
|
|
318
|
+
- Are repository interfaces aggregate-oriented?
|
|
319
|
+
- Are domain events facts rather than commands?
|
|
320
|
+
- Are application services orchestrating rather than owning the model?
|
|
321
|
+
- Are foreign models translated explicitly?
|
|
322
|
+
- Did we avoid shared-model shortcuts across contexts?
|
|
323
|
+
|
|
324
|
+
If any answer is no, revise before shipping.
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Final Instruction
|
|
329
|
+
|
|
330
|
+
When uncertain, choose the option that:
|
|
331
|
+
1. protects the bounded context
|
|
332
|
+
2. keeps aggregates small
|
|
333
|
+
3. keeps identities explicit
|
|
334
|
+
4. preserves local language
|
|
335
|
+
5. moves cross-boundary coordination toward events and translation rather than shared object graphs
|
|
336
|
+
|
|
337
|
+
Reject DDD theater and model the real operational domain.
|
package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.mini.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# OBEY Implementing Domain-Driven Design by Vaughn Vernon
|
|
2
|
+
|
|
3
|
+
## When to use
|
|
4
|
+
|
|
5
|
+
Use when DDD implementation choices affect bounded contexts, language, aggregates, repositories, events, application services, package structure, or cross-context integration.
|
|
6
|
+
|
|
7
|
+
## Primary bias to correct
|
|
8
|
+
|
|
9
|
+
Practical DDD is not renamed CRUD. Model the operational domain inside an explicit Bounded Context, with local language, small invariant boundaries, identity references across Aggregates, and explicit translation across context and infrastructure boundaries.
|
|
10
|
+
|
|
11
|
+
## Decision rules
|
|
12
|
+
|
|
13
|
+
- Name the Bounded Context before interpreting terms, modules, services, repositories, events, APIs, persistence, or integrations; never force one global company model.
|
|
14
|
+
- Use the local Ubiquitous Language consistently: one concept gets one term inside the context, one term must not carry multiple meanings, and code, tests, events, commands, repositories, services, and packages must speak that language.
|
|
15
|
+
- Protect the Core Domain from generic abstractions and vendor terms; spend richer modeling where competitive or operational complexity lives, keep supporting subdomains simpler, and avoid DDD ceremony for trivial CRUD.
|
|
16
|
+
- Make every context interaction explicit: show the relationship, translation responsibility, and upstream/downstream influence before sharing data, terms, models, or integration code.
|
|
17
|
+
- Translate foreign, legacy, partner, external, and infrastructure models into the local language; keep foreign schemas, statuses, contract models, and aggregates out of local domain objects.
|
|
18
|
+
- Treat Aggregates as immediate consistency boundaries: keep them small, expose one root, route invariant-changing behavior through the root, hide mutable internals, and expose intention-revealing behavior instead of arbitrary setters.
|
|
19
|
+
- Reference other Aggregates by identity, avoid large connected object graphs, and default to one Aggregate per transaction; use events, policies, or process coordination when consistency can be eventual.
|
|
20
|
+
- Use Entities when identity and lifecycle matter, and make their methods protect meaningful state transitions rather than generic state changes.
|
|
21
|
+
- Use immutable Value Objects for meaningful descriptive concepts; validate at construction, compare by value, and replace raw primitives for meaningful identifiers, quantities, ranges, names, and whole values.
|
|
22
|
+
- Use Domain Services only for domain-significant operations that require multiple domain objects and fit no Entity or Value Object; keep technical transformation, serialization, transport, and persistence mapping outside the domain model.
|
|
23
|
+
- Provide Repositories for Aggregate Roots, not tables; define interfaces by domain or application needs, return domain objects or domain-oriented results, and keep business rules out of repository implementations.
|
|
24
|
+
- Publish Domain Events only for meaningful completed business facts; name them in the past tense, keep payloads local to the model, and do not use events for every property change or to hide poor Aggregate design.
|
|
25
|
+
- Use Event Sourcing only when the event sequence is the right persistence model; streams must match Aggregate identity and versioning, replay must be deterministic, and event meaning changes need versioning, upcasters, or translators.
|
|
26
|
+
- Keep Application Services as use-case coordinators: load Aggregates, invoke domain behavior, persist results, publish resulting events, own transaction or integration coordination, and keep core decisions in the domain model.
|
|
27
|
+
- Organize modules by Bounded Context first and by domain or use-case ownership within the context; avoid giant `shared` or `common` packages for domain concepts.
|
|
28
|
+
- Use DTOs, projections, use-case queries, rendition adapters, or mediators when client needs differ from Aggregate shape; expose application-facing representations rather than aggregate internals.
|
|
29
|
+
- Keep command behavior separate from query models when consistency, performance, or representation needs justify it, and keep scope identifiers explicit where context or ownership affects invariants or access.
|
|
30
|
+
- When generating code, walk the model in order: context, language terms, tactical type, conservative Aggregate boundary, identity references, local invariants, Aggregate-oriented repositories, use-case services, and boundary translations.
|
|
31
|
+
- Test domain behavior and boundaries directly: Aggregate invariants, valid and invalid state transitions, Value Object validation, Domain Events as outcomes, repositories as infrastructure, translation layers, and application-service orchestration.
|
|
32
|
+
|
|
33
|
+
## Trigger rules
|
|
34
|
+
|
|
35
|
+
- When a term is ambiguous, reused across contexts, or drifting into a technical placeholder, qualify, split, or rename it before coding further.
|
|
36
|
+
- When code wants to import another context's domain package, share enums across contexts, or couple through another context's database, add explicit translation instead.
|
|
37
|
+
- When legacy, vendor, partner, API, transport, persistence, or UI shape appears in local domain code, add an Anticorruption Layer or mapping boundary before modeling locally.
|
|
38
|
+
- When an Aggregate boundary changes or one transaction wants multiple Aggregates, list the immediate invariants that require it; otherwise coordinate by identity, Domain Events, policies, processes, or Application Services.
|
|
39
|
+
- When external code mutates Aggregate internals or reads internals to decide state changes, move the operation behind root behavior.
|
|
40
|
+
- When a Repository becomes generic CRUD, table-shaped, row-returning, or starts enforcing business rules, reshape it around Aggregate access and move rules back to the model.
|
|
41
|
+
- When an event reads like a command, exposes framework or persistence artifacts, or describes a minor property change, rename, narrow, or remove it.
|
|
42
|
+
- When Application Services or controllers accumulate branching business rules, move the decision into the Entity, Value Object, Aggregate, or Domain Service that owns the concept.
|
|
43
|
+
- When client rendering, query speed, or representation needs pressure the model shape, use projections, DTOs, use-case queries, or adapters instead of enlarging or exposing Aggregates.
|
|
44
|
+
- When a subdomain is simple CRUD, keep it simple; when invariants and lifecycle complexity appear, model them honestly instead of hiding them in services.
|
|
45
|
+
|
|
46
|
+
## Final checklist
|
|
47
|
+
|
|
48
|
+
- Is the Bounded Context explicit before interpreting names, modules, events, repositories, APIs, persistence, or integrations?
|
|
49
|
+
- Does the code use one local term per concept across tests, commands, events, repositories, services, and packages?
|
|
50
|
+
- Is Core Domain effort protected while supporting or CRUD areas stay simpler?
|
|
51
|
+
- Are context relationships, translation responsibilities, and upstream/downstream pressures visible?
|
|
52
|
+
- Are Aggregates small, root-protected, invariant-driven, identity-linked, and usually one per transaction?
|
|
53
|
+
- Are Entities behavior-bearing and Value Objects immutable, validated, and value-equal?
|
|
54
|
+
- Are Repositories Aggregate-root access points rather than generic DAOs or ORM leaks?
|
|
55
|
+
- Are Domain Events meaningful past-tense facts, and is Event Sourcing used only when event history is the right persistence model?
|
|
56
|
+
- Are Application Services coordinating use cases instead of owning domain decisions?
|
|
57
|
+
- Are client, foreign, persistence, and infrastructure representations kept outside the local domain model?
|
package/templates/skills/implementing-domain-driven-design/implementing-domain-driven-design.nano.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# OBEY Implementing Domain-Driven Design by Vaughn Vernon
|
|
2
|
+
|
|
3
|
+
## When to use
|
|
4
|
+
|
|
5
|
+
Use when tight context still needs DDD guardrails for context leakage, fake tactical patterns, Aggregate sprawl, and cross-context model coupling.
|
|
6
|
+
|
|
7
|
+
## Primary bias to correct
|
|
8
|
+
|
|
9
|
+
Local context, language, and invariants outrank reuse pressure, ORM convenience, object graph traversal, and framework or client shape.
|
|
10
|
+
|
|
11
|
+
## Decision rules
|
|
12
|
+
|
|
13
|
+
- Name the Bounded Context and local Ubiquitous Language before interpreting models, services, repositories, events, APIs, persistence, or integrations.
|
|
14
|
+
- Translate across contexts and foreign systems; never share local Aggregates, Entities, enums, or domain objects as integration contracts.
|
|
15
|
+
- Treat Aggregates as small immediate consistency boundaries with one root, hidden mutable internals, identity references to other Aggregates, and eventual consistency outside one boundary by default.
|
|
16
|
+
- Use Entities for identity and lifecycle, Value Objects for immutable validated descriptive values, and Domain Services only when no model object naturally owns the operation.
|
|
17
|
+
- Keep Repositories focused on Aggregate Roots and Application Services focused on use-case coordination rather than domain decisions.
|
|
18
|
+
- Publish Domain Events only as meaningful completed past-tense facts; use Event Sourcing only when event history is the right persistence model.
|
|
19
|
+
- Use DTOs, projections, use-case queries, adapters, and explicit scope identifiers instead of exposing or reshaping domain internals for clients.
|
|
20
|
+
|
|
21
|
+
## Trigger rules
|
|
22
|
+
|
|
23
|
+
- When a term is ambiguous, generic, or reused across contexts, split or qualify it by Bounded Context before coding.
|
|
24
|
+
- When one transaction or object graph wants multiple Aggregate roots, demand immediate-invariant proof; otherwise coordinate by identity, events, policies, processes, or Application Services.
|
|
25
|
+
- When foreign models, database shape, framework objects, transport payloads, UI needs, or another context's model leak into domain code, translate at the boundary.
|
|
26
|
+
- When DDD vocabulary appears around CRUD services, generic repositories, mutable graphs, or anemic models, require the real invariant and behavior or simplify the design.
|
|
27
|
+
- When reviewing DDD code, verify context, language, Aggregate boundary, translation, Repository shape, events-as-facts, and Application Service thinness before approving.
|
|
28
|
+
|
|
29
|
+
## Final checklist
|
|
30
|
+
|
|
31
|
+
- Clear Bounded Context and local language?
|
|
32
|
+
- Explicit translation instead of shared model types?
|
|
33
|
+
- Aggregate boundary backed by immediate invariants?
|
|
34
|
+
- Identity references across Aggregates?
|
|
35
|
+
- Repositories Aggregate-root focused?
|
|
36
|
+
- Application Services coordinating, not deciding?
|
|
37
|
+
- Client, persistence, and foreign concerns kept outside the domain model?
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: patterns-of-enterprise-application-architecture
|
|
3
|
+
description: Apply Martin Fowler-inspired enterprise architecture rules when choosing layers, service layers, transaction scripts, domain models, repositories, mappers, or DTOs.
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Patterns of Enterprise Application Architecture Skill
|
|
8
|
+
|
|
9
|
+
Use this skill when a task involves enterprise application structure, layering, service layer, transaction script, domain model, data mapper, repository, unit of work, identity map, DTOs, or integration patterns.
|
|
10
|
+
|
|
11
|
+
Before making design or code decisions, read and apply [patterns-of-enterprise-application-architecture.mini.md](patterns-of-enterprise-application-architecture.mini.md). Use [patterns-of-enterprise-application-architecture.md](patterns-of-enterprise-application-architecture.md) only as a deeper reference when the mini rules are not enough for the current enterprise-pattern tradeoff.
|