domain-driven-design
Skill197 starsChanged 3 months agoMITView on GitHub
Apply DDD tactical patterns when working with domain code, and validate proposed domain models before approval (design mode). Enforces aggregate design, value objects over primitives, entity identity rules, and bounded context boundaries. Use when creating or modifying domain models, designing aggregates, working in the domain layer, or when the user mentions 'domain', 'aggregate', 'value object', 'entity', 'bounded context', or 'DDD'.
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
- eralmansouri/skillstheir own version, first seen Aug 20, 2026
- rrezartprebreza/spring-boot-skillstheir own version, first seen Aug 7, 2026
- wondelai/skillstheir own version, first seen Jul 16, 2026
Used with
Projects with it also use clean-architecture and hexagonal-architecture.
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
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
- booklib-ai/booklib★ 38same 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 repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architecture-compassSkill
- architecture-refinerSkill
- architectureSkill
- bug-fixSkill
- clean-code-refinerSkill
- clean-codeSkill
- code-forgeSkill
- collaborative-judgmentSkill
- context-anchoringSkill
- ddd-refinerSkill
- design-blueprintSkill
- design-firstSkill
- knowledge-priming-refinerSkill
- knowledge-primingSkill
- language-idioms-refinerSkill
- lattice-initSkill
- learning-harvestSkill
- refactor-safelySkill
- refiners-updateSkill
- requirement-forge-refinerSkill
- requirement-forgeSkill
- requirement-qualitySkill
- review-refinerSkill
- reviewSkill
- secure-codingSkill
- test-qualitySkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 7 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 14 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Look for .lattice/config.yaml in the repo root.
- Very specific: line 12
If found, check paths.ddd_principles for a custom doc path.
- Very specific: line 13
If a custom document exists at that path, read it and check its YAML frontmatter mode:
- Distinctive: line 15
Use it instead of the embedded default.
- Very specific: line 19
If a custom path is configured but no document exists at it → tell the user which configured path is missing, then read …
- Very specific: line 20
If there is no config file or no paths.ddd_principles key → read ./references/defaults.md.
- Distinctive: line 32
DOMAIN EVENTS: Should a domain event be raised — a state transition another aggregate reacts to, a change triggering notification, an …
- Distinctive: line 36
All checks pass → state "Passes domain-driven-design.
- Distinctive: line 40
After verifying the checklist above, scan the output for these specific anti-patterns.
- Distinctive: line 66
When invoked during design — no code is being written.
- Distinctive: line 69
Run the Self-Validation Checklist and Active Anti-Pattern Scan against it — before the model is presented for user approval.
- Distinctive: line 71
STOP: do not skip evaluation because no code exists yet — the proposed model is what gets validated.
“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
Config Resolution
The skill supports project-custom principles. Resolution:
- Look for
.lattice/config.yamlin the repo root. - If found, check
paths.ddd_principlesfor a custom doc path. - If a custom document exists at that path, read it and check its YAML frontmatter
mode:mode: override: the custom doc has full precedence. Use it instead of the embedded default. It must be comprehensive -- sole reference.mode: overlay(or no mode): read the embedded./references/defaults.mdfirst, then apply the custom doc on top. A custom section replaces the matching default section (matched by heading); new sections append after the defaults.
- If a custom path is configured but no document exists at it → tell the user which configured path is missing, then read
./references/defaults.md. - If there is no config file or no
paths.ddd_principleskey → read./references/defaults.md. - Language adaptation: if
paths.language_idiomsis set in the config and the document exists, read its "Type System & Object Model" section and adapt entity, value object, and aggregate implementation patterns to language constructs (e.g., struct vs class, trait vs interface, data class vs record). Language idioms take precedence over pseudocode defaults.
Self-Validation Checklist
STOP after generating each component. Verify ALL checks before proceeding. If any check fails, fix before presenting. If a check is a judgment call with multiple valid approaches (see Ambiguity Signals), flag it — present options and reasoning rather than silently choosing; if framework:collaborative-judgment is loaded, use its presentation format.
- ENTITY VS VALUE OBJECT: For each domain object — does the business track individual instances over time? Yes → entity with identity. No → value object, immutable and self-validating.
- AGGREGATE BOUNDARY: Does a transactional invariant require this object inside the aggregate? If not → reference it from a separate aggregate by ID.
- RICH BEHAVIOR: Does the entity have methods that enforce business rules, guard state transitions, raise events? If the entity is just a data holder → move logic from services into the entity.
- VALUE OBJECT COVERAGE: Scan for primitives that should be value objects — string emails, number amounts, raw UUIDs as identifiers → wrap in a validating value object.
- AGGREGATE COHESION: List the business rules the root enforces. Does every internal entity participate in at least one invariant? If not → it belongs in its own aggregate.
- DOMAIN EVENTS: Should a domain event be raised — a state transition another aggregate reacts to, a change triggering notification, an audit/compliance requirement? Do not raise events for internal changes nothing reacts to.
- DOMAIN SERVICE: Does stateless logic spanning multiple entities belong in a domain service rather than an application service? Keep I/O and infrastructure calls out of it.
- FACTORY: Is complex aggregate creation encapsulated behind a factory method (
Order.create(...)) or a standalone factory class? Are initial creation and reconstitution from persistence handled separately?
All checks pass → state "Passes domain-driven-design. [next step]."
Active Anti-Pattern Scan
After verifying the checklist above, scan the output for these specific anti-patterns. If you find any, fix before presenting.
- Anemic Domain Model: Entity is a getter/setter data holder; all logic lives in services → move business rules into entities and value objects
- Primitive Obsession: Raw string for email, number for money, UUID for ID → wrap in a validating value object with behavior
- God Aggregate: Aggregate has many entities, loads slowly, high contention → decompose; keep only what shares a transactional invariant
- Cross-Aggregate Transaction: Service updates two aggregates in one transaction → use domain events and eventual consistency
- Leaking Domain Logic: Business rule in a controller, application service, or infrastructure → extract into a domain object or domain service
- Misidentified Entity/Value Object: Entity without a lifecycle, or value object with tracked identity → apply the identity test
Ambiguity Signals
These checks often have multiple valid outcomes. When you encounter one, present the options rather than silently choosing. If framework:collaborative-judgment is loaded, use its presentation format.
- Aggregate Boundary Size: Small aggregate (more events, eventual consistency) vs large aggregate (simple transaction, immediate consistency). Neither is inherently correct — it depends on contention patterns and invariant scope.
- Entity vs Value Object: Some concepts (like
AddressorMoney) may or may not need identity depending on domain complexity. Apply the identity test, but acknowledge when borderline. - Domain Service vs Entity Method: Logic spanning multiple entities could live in a domain service or be a method on the primary entity. The choice depends on which entity "owns" the invariant.
- Object Creation Pattern: Factory method on the aggregate root, standalone factory class, builder pattern, or plain constructor — depends on assembly complexity and team convention. Don't prescribe a pattern; ask which approach the team prefers.
Scope Statement
This skill operates within a single repo, single bounded context (e.g., one API -- Order, User, Pricing). It covers tactical DDD patterns only -- not strategic DDD (no context maps, no microservice topology, no bounded-context integration).
If a task appears to span multiple bounded contexts (e.g., an Order feature calling Shipping logic), flag before proceeding: "This task touches [Context A] and [Context B]. Cross-context integration is strategic DDD — outside this skill's scope. Would you like to scope to one context, or proceed knowing cross-context coordination is your responsibility?"
Design Mode
When invoked during design — no code is being written; a planning molecule is validating a proposed domain model — apply the same checks as a forward-looking validation:
- Take the proposed artifact (aggregate list, entity/value object classification, event set, or contract types) as the unit of validation.
- Run the Self-Validation Checklist and Active Anti-Pattern Scan against it — before the model is presented for user approval.
- Report violations as concrete findings on the model ("Order aggregates both pricing and fulfillment state — split by transactional invariant"), not generic advice. Resolve them through the design.
- STOP: do not skip evaluation because no code exists yet — the proposed model is what gets validated.
See ./references/defaults.md for aggregate design rules, entity/value object/domain service/domain event/repository/creation patterns with code examples, inline anti-pattern warnings, and a decomposition guide.
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.

