/design-patterns:domain-modelingfrom design-patterns
Use when business objects have no behaviour (anemic model), invariants are enforced in services or controllers instead of domain classes, ownership of business rules is unclear, or the code allows states the business forbids. Apply before designing or reviewing any business domain class. Covers DDD tactical patterns: Entity, Value Object, Aggregate, Aggregate Root.
Ships in design-patterns. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Sources: Eric Evans — Domain-Driven Design (2003); Martin Fowler — PoEAA (2002)
An object defined by its identity, not its attributes. Two entities with the same values are still different if they have different IDs.
When to use: the object has a lifecycle, changes over time, and must be tracked individually.
class Order:
id: OrderId # identity — never changes
status: OrderStatus # state — changes over lifecycle
items: list[LineItem]
def add_item(self, product: Product, quantity: int) -> None:
# business rule enforced at mutation point
if self.status != OrderStatus.DRAFT:
raise InvalidOperation("Cannot add items to a submitted order")
self._items.append(LineItem(product, quantity))
Invariant rule: state mutations go through methods that enforce business rules — never via direct field assignment from outside the class.
An object defined entirely by its attributes. Immutable. Equality by value. No identity.
When to use: the concept has no lifecycle of its own; two instances with identical values are interchangeable; the value represents a measurement, descriptor, or range.
class Money:
def __init__(self, amount: Decimal, currency: Currency):
if amount < 0:
raise ValueError("Amount cannot be negative")
self._amount = amount
self._currency = currency
def add(self, other: 'Money') -> 'Money':
if self._currency != other._currency:
raise CurrencyMismatch()
return Money(self._amount + other._amount, self._currency)
# returns NEW instance — never mutates self
def __eq__(self, other):
return self._amount == other._amount and self._currency == other._currency
Common violation: adding an id field to a value object. If it needs an ID, it is an Entity.
When NOT to use: when you need to track the object through changes across transactions. Use an Entity instead.
A cluster of domain objects (Entities and Value Objects) treated as a single unit for the purpose of data changes. Has exactly one Aggregate Root.
Consistency boundary: all invariants that span multiple objects within the cluster are enforced inside the aggregate. No invariant should span two aggregates — that requires eventual consistency via Domain Events.
class Order: # Aggregate Root
id: OrderId
items: list[LineItem] # internal — part of aggregate
total: Money # value object — part of aggregate
def submit(self) -> None:
if not self._items:
raise EmptyOrderError("Cannot submit an order with no items")
if self._total > self._customer.credit_limit:
raise CreditLimitExceeded()
self._status = OrderStatus.SUBMITTED
self._record_event(OrderSubmitted(self.id))
Rules:
Sizing heuristic: if two things must always be consistent within a single transaction, they belong in the same aggregate. If eventual consistency is acceptable, split them — smaller aggregates have less contention.
The single Entity in an aggregate that external objects are permitted to reference. Controls all access to the aggregate's internals.
Common violations to catch in review:
lineItem.discount = ... from a service)LineItemRepository when LineItem is internal to Order)What SKILL.md sets; muted values are Claude Code's defaults
10 skills in this plugin
/anti-corruptionUse when external system types, vocabulary, or conventions bleed into your domain model, a single provider change would require touching many internal files, or a legacy system must keep running while a new one is built alongside it. Apply before writing any integration with an external API, legacy codebase, or third-party service. Covers Anti-Corruption Layer, Gateway, Facade, and Strangler Fig./behaviouralUse when behaviour varies across cases, accumulates conditionals, or needs to be decoupled, queued, undone, or observed. Apply when a method is growing if/switch branches, an algorithm differs per context, a pipeline needs flexible steps, or objects need to react to each other without tight coupling. Covers all 10 GoF behavioural patterns./cqrsUse when read and write performance requirements diverge significantly, complex reporting is painful through the domain model, or you need to scale reads and writes independently. Apply before splitting any command/query handler or building read-optimised projections. Covers Command Query Responsibility Segregation — including when it is overkill — with guidance on applying only as much separation as the problem demands./creationalUse when object creation is the source of pain — constructors growing too complex, the same setup repeated, unclear which concrete type to instantiate, or a shared instance causing hidden coupling. Apply before writing any factory, builder, or instantiation logic. Covers all 5 GoF creational patterns: Singleton, Builder, Factory Method, Abstract Factory, Prototype./data-accessUse when persistence logic bleeds into domain or business code, tests require a real database to verify business logic, ORM types appear in service or handler code, or switching storage would require touching domain classes. Apply before writing any database query, repository, or ORM integration. Covers Repository, Unit of Work, Data Mapper, and Active Record with explicit guidance on when each applies./domain-eventsUse when aggregates need to stay loosely coupled, side effects (emails, audit logs, projections) are tangled into domain operations, or one aggregate directly calls methods on another. Apply when something significant happens in the domain that other parts of the system need to react to without being tightly coupled. Covers Domain Events, publishing patterns, synchronous vs asynchronous handling, idempotency, and eventual consistency trade-offs.npx claudepluginhub entelligentsia/skillforge --plugin design-patternsOther plugins' skills for the same job