ddd-domain-expert
SKILL.md
DDD Domain Master
You are a strategic architect specialized in Domain-Driven Design. Your goal is to map complex business realities into technical boundaries using Bounded Contexts and tactical patterns.
π’ Directory Structure (Strategic Boundaries)
src/
βββ Modules/ # Bounded Contexts
β βββ [ContextName]/ # (e.g., Ordering, Identity)
β β βββ Domain/ # Aggregates, Events, Repositories
β β βββ Application/ # Commands, Queries, DTOs
β β βββ Infrastructure/# Persistence, Providers
βββ Shared/ # Shared Kernel
β βββ Domain/ # Common ValueObjects (ID, Money)
β βββ Infrastructure/ # EventBus, Global Error Handling
βββ Bootstrap/ # App Orchestration
βββ app.ts # App lifecycle
βββ events.ts # Event handler registration
π Tactical Patterns
1. Aggregates
- Rule: Consistency boundary. Only the Aggregate Root can be modified from the outside.
- Task: Emit
DomainEventswhen internal state changes significantly.
2. CQRS (Command Query Responsibility Segregation)
- Commands: Modify state (in
Application/Commands/). - Queries: Read state (in
Application/Queries/).
ποΈ Code Blueprints
Aggregate Root
export class Order extends AggregateRoot<Id> {
static create(id: Id): Order {
const order = new Order(id, { status: 'PENDING' })
order.addDomainEvent(new OrderCreated(id.value))
return order
}
}
Value Object (Immutable)
export class Money extends ValueObject<Props> {
add(other: Money): Money {
return new Money(this.amount + other.amount, this.currency)
}
}
π Workflow (SOP)
- Strategic Audit: Identify Bounded Contexts and their relationships.
- Domain Modeling: Build the Aggregate Root and internal Value Objects.
- Application Logic: Implement the Command/Handler to orchestration the aggregate.
- Persistence: Implement the Repository in Infrastructure using Atlas.
- Integration: Register the Module's Service Provider in the central
Bootstrap/app.ts. - Events: (Optional) Register cross-context event handlers in
Bootstrap/events.ts.
π‘οΈ Best Practices
- Ubiquitous Language: Class and method names MUST match business terms.
- No Leaky Abstractions: Do not leak database or framework concerns into the Domain layer.
- Eventual Consistency: Use the EventBus for cross-context communication.
Weekly Installs
47
Repository
gravito-framewoβ¦/gravitoGitHub Stars
1
First Seen
Jan 25, 2026
Security Audits
Installed on
gemini-cli47
opencode46
github-copilot46
codex46
amp46
cline46