Domain-Driven Design skill. Activates when user needs to model a complex domain, define bounded contexts, design aggregates, or facilitate event storming. Covers strategic design (bounded contexts, context mapping, ubiquitous language) and tactical design (aggregates, entities, value objects, domain events, repositories). Produces bounded context maps, aggregate boundary diagrams, domain event catalogs, and implementation scaffolds. Triggers on: /godmode:ddd, "model the domain", "bounded context", "aggregate design", "event storming", or when the orchestrator detects domain modeling needs.
From godmodenpx claudepluginhub arbazkhan971/godmodeThis skill uses the workspace's default tool permissions.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
/godmode:ddd/godmode:architect identifies that domain boundaries need clarification/godmode:pattern detects an anemic domain model anti-patternUnderstand the business domain before modeling:
DOMAIN CONTEXT:
Business: <what does the business do?>
Core domain: <the thing that differentiates this business>
Supporting domains: <necessary but not differentiating>
Generic domains: <commodity ā auth, billing, email>
Key stakeholders: <who are the domain experts?>
Known pain points: <where does the current model break down?>
Identify the core domain. This is where you invest the most modeling effort. Generic domains get off-the-shelf solutions. Supporting domains get simple implementations. Only the core domain gets full DDD treatment.
Establish the shared vocabulary between developers and domain experts:
UBIQUITOUS LANGUAGE ā <Domain Name>:
| Term | Definition |
|--|--|
| <Term 1> | <Precise definition as understood by domain experts |
| | AND developers. No ambiguity.> |
| <Term 2> | <Definition. Note: "Order" in the Sales context |
| | means something different than in Fulfillment.> |
| <Term 3> | <Definition. Include what it is NOT if ambiguous.> |
LANGUAGE RULES:
- These terms are used in code (class names, method names, variable names)
- These terms are used in conversations with stakeholders
- If a term means different things in different contexts, it belongs in
different bounded contexts with different definitions
- When a new term emerges, add it to this glossary immediately
Facilitate a structured event storming session to discover domain events, commands, aggregates, and boundaries:
List every domain event ā things that happened in the past tense:
DOMAIN EVENTS (unordered):
š§ OrderPlaced
š§ PaymentReceived
š§ PaymentFailed
š§ InventoryReserved
š§ InventoryOutOfStock
š§ OrderShipped
š§ OrderDelivered
š§ OrderCancelled
š§ RefundIssued
š§ CustomerRegistered
š§ PriceChanged
š§ PromotionApplied
Arrange events in chronological order:
TIMELINE:
CustomerRegistered ā OrderPlaced ā InventoryReserved ā PaymentReceived
ā OrderShipped ā OrderDelivered
ALTERNATE FLOWS:
OrderPlaced ā InventoryOutOfStock ā OrderCancelled ā RefundIssued
OrderPlaced ā InventoryReserved ā PaymentFailed ā OrderCancelled
OrderShipped ā OrderDelivered ā RefundIssued (return)
Identify what triggers each event:
COMMANDS AND TRIGGERS:
| Command | Actor | Produces Event |
|--|--|--|
| PlaceOrder | Customer | OrderPlaced |
| ProcessPayment | Payment Gateway | PaymentReceived |
| ReserveInventory | System (auto) | InventoryReserved |
| ShipOrder | Warehouse Staff | OrderShipped |
| CancelOrder | Customer/System | OrderCancelled |
| IssueRefund | Support Agent | RefundIssued |
Group events around the entities that own them:
AGGREGATES:
<<Aggregate>> Order
Commands: PlaceOrder, CancelOrder
Events: OrderPlaced, OrderCancelled,
OrderShipped, OrderDelivered
Invariants:
- Order total stays > 0
- Cannot cancel a delivered order
- Cannot ship without payment
<<Aggregate>> Inventory
Commands: ReserveInventory, ReleaseInventory
Draw boundaries around aggregates that share a ubiquitous language:
BOUNDED CONTEXTS (list each with its aggregates and ubiquitous language):
[ORDERING CONTEXT]
Aggregates: Order, Cart
"Order" here means: items a customer wants to buy
[FULFILLMENT CONTEXT]
Aggregates: Shipment, Inventory
"Order" here means: items to pick and ship from warehouse
Define relationships between bounded contexts:
CONTEXT MAP:
Ordering āāāā Partnership āāāāāŗ Fulfillment
ā ā ā ā
Customer/ Customer/
Supplier Supplier
ā ā ā ā
ā¼ ā¼
Billing āāāā Conformist āāāāāŗ Payment Gateway (External)
Identity āāāā Open Host Service āāāāāŗ All Contexts
(Published Language)
Reporting āāāā ACL āāāāāŗ Legacy ERP System
For each aggregate in the core domain, design the internal structure:
AGGREGATE DESIGN ā <Aggregate Name>:
Root Entity: <AggregateRootName>
ID: <type and generation strategy>
State: <key properties>
Invariants:
1. <business rule that must always be true>
2. <business rule that must always be true>
Entities (within this aggregate):
- <EntityName>: <purpose, ID type, key properties>
- <EntityName>: <purpose, ID type, key properties>
Value Objects:
- <ValueObjectName>: <immutable, defined by attributes not identity>
AGGREGATE BOUNDARY RULES:
1. CONSISTENCY BOUNDARY: Everything inside an aggregate is immediately
consistent. Cross-aggregate operations are eventually consistent.
2. TRANSACTION BOUNDARY: One aggregate = one transaction. Never modify
two aggregates in the same transaction.
3. SIZE RULE: Keep aggregates small. If an aggregate has more than
3-4 entities, split it.
4. REFERENCE RULE: Aggregates reference each other by ID only, never
by direct object reference.
5. CASCADE RULE: External code references only the aggregate root.
Internal entities are accessed through the root.
Document all domain events for cross-context communication:
DOMAIN EVENT CATALOG:
| Event | Source | Payload |
| | Context | |
| OrderPlaced | Ordering | orderId, customerId, items[], |
| | | totalAmount, placedAt |
| PaymentReceived | Billing | paymentId, orderId, amount, |
| | | method, paidAt |
| InventoryReserved | Fulfillment | reservationId, orderId, items[], |
| | | warehouseId, reservedAt |
| OrderShipped | Fulfillment | shipmentId, orderId, trackingNo, |
Generate the directory structure and skeleton code:
DIRECTORY STRUCTURE:
src/
āāā <context-name>/
ā āāā domain/
ā ā āāā model/
ā ā ā āāā <AggregateRoot>.ts # Aggregate root entity
ā ā ā āāā <Entity>.ts # Child entities
ā ā ā āāā <ValueObject>.ts # Value objects
ā ā āāā events/
ā ā ā āāā <DomainEvent>.ts # Domain events
ā ā āāā commands/
ā ā ā āāā <Command>.ts # Commands
ā ā āāā repositories/
ā ā ā āāā <Repository>.ts # Repository interface (port)
ā ā āāā services/
docs/domain/<context>-domain-model.mddocs/domain/event-catalog.mddocs/domain/context-map.mddocs/domain/ubiquitous-language.md"ddd: <context> ā bounded contexts, aggregates, and event catalog"/godmode:architect to select the architecture for this domain."/godmode:plan to decompose aggregate implementation into tasks."/godmode:pattern to select implementation patterns for each aggregate."Never ask to continue. Loop autonomously until done.
# Detect domain model patterns in codebase
grep -rn "class.*Aggregate\|class.*Entity\|class.*ValueObject" src/ --include="*.ts" --include="*.py"
grep -rn "Event\|EventHandler\|DomainEvent" src/ --include="*.ts" --include="*.py" | head -20
IF aggregate has > 4 entities: split into smaller aggregates. WHEN same term means different things in 2 contexts: correct ā separate glossary entries. IF domain events > 50: group by context, verify no cross-context coupling.
| Flag | Description |
|---|---|
| (none) | Full DDD session: discovery, event storming, contexts, tactical design |
--strategic | Strategic design only (bounded contexts, context map, ubiquitous language) |
--tactical | Tactical design only (aggregates, entities, value objects, events) |
timestamp domain bounded_contexts aggregates events value_objects verdict
AUTO-DETECT:
1. Scan for domain dirs: find src/ -type d -name "domain" -o -name "aggregates" -o -name "events"
2. Scan for domain objects: grep -r "class.*Entity\|class.*Aggregate\|class.*ValueObject" src/ -l
3. Scan for domain events: grep -r "Event\|EventHandler\|EventBus" src/ -l
4. Anemic model detection: models with only getters/setters, no behavior methods
Print on completion:
DDD SESSION: {domain_name}
Core domain: {core_domain_name}
KEEP if: improvement verified. DISCARD if: regression or no change. Revert discards immediately.
Stop when: target reached, budget exhausted, or >5 consecutive discards.