Design rich domain aggregates with proper encapsulation, domain events, and the Export pattern. Use when implementing DDD aggregates with event sourcing patterns.
75%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./dotfiles/shared/.config/claude/forgoty-marketplace/plugins/software-engineering/skills/ddd-aggregate-design/SKILL.mdDesign and implement rich domain aggregates with proper encapsulation, domain events, and the Export pattern.
Read DDD-RULES.md for all aggregate design rules. Key principles:
Export() to expose state externallyfunc NewOrder(customerID CustomerID, items []OrderItem) (*Order, error) {
if len(items) == 0 {
return nil, ErrEmptyOrder
}
o := &Order{
id: NewOrderID(),
status: OrderStatusPending,
events: &eventRegister{},
}
o.addEvent(applayer.NewEvent(OrderCreated{OrderID: o.id}))
return o, nil
}func (o *Order) Ship(warehouse WarehouseID) error {
if o.status == OrderStatusCancelled {
return ErrOrderAlreadyCancelled
}
if o.status == OrderStatusShipped {
return nil // Idempotent
}
oldStatus := o.status
o.status = OrderStatusShipped
o.addEvent(applayer.NewEvent(OrderShipped{OldStatus: oldStatus}))
return nil
}func (o *Order) Export() ExportedOrder {
return ExportedOrder{
ID: o.id.String(),
Status: string(o.status),
}
}
func (o *Order) ID() OrderID { return o.id } // Only identity getter allowedforgoty/dotfiles
fb95c17
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.