ddd-domain-building-blocks

Guides design of DDD value objects, entities, aggregates, and domain services.

Updated Jun 23, 2026
One-click install
npx skills add https://github.com/j5ik2o/marp-ai-base --skill ddd-domain-building-blocks-j5ik2o
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ddd-domain-building-blocks
Source: https://github.com/j5ik2o/marp-ai-base/tree/main/.agents/skills/ddd-domain-building-blocks
Command: npx skills add https://github.com/j5ik2o/marp-ai-base --skill ddd-domain-building-blocks-j5ik2o

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing domain models in Domain-Driven Design requires deciding when to use value objects versus entities, where to draw aggregate boundaries, and how to place cross-entity logic in domain services. This Skill provides language-agnostic design guidance with TypeScript examples so you can model your domain correctly from the start. ## Core Features & Use Cases - Value Object Design: Explains identity-free, immutable, self-contained value objects with validation via smart constructors, using a Money class with fp-ts Either-based error handling as the example. - Entity and Aggregate Modeling: Covers identifier-based entities with lifecycles and aggregates as transactional consistency units accessed only through an aggregate root, illustrated with an Order aggregate. - Domain Services: Shows how to implement operations spanning multiple entities, such as a bank account transfer, as domain services or standalone functions named after the ubiquitous language. - Use Case: When building an order management system, use this Skill to decide that Order is an aggregate root enforcing invariants like "no items after confirmation", while Money and Quantity become immutable value objects. ## Quick Start Ask the AI to help you design a value object or aggregate for your domain, for example by saying "Help me design a Money value object and an Order aggregate using DDD principles".

Frequently Asked Questions about ddd-domain-building-blocks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the difference between an entity and a value object in DDD?

An entity has a unique identifier and a lifecycle whose state changes over time, while a value object has no identifier and is compared only by its attributes. Value objects are immutable and self-contained, whereas entities like Order are equal when their identifiers match.

How do I decide aggregate boundaries in domain-driven design?

Define an aggregate as the unit of transactional consistency, containing one aggregate root plus child entities and value objects. External code may only access the aggregate through its root, which enforces invariants such as rejecting item additions after an order is confirmed.

When should I use a domain service instead of entity methods?

Use a domain service when an operation spans multiple entities or value objects and does not naturally belong to any single one, such as transferring money between two bank accounts. Name the service after the ubiquitous language, like BankAccountTransfer.

How do I validate value objects without throwing exceptions?

Use a smart constructor pattern that returns an Either type instead of throwing, as shown with fp-ts in the Money example. A static validate method catches illegal argument errors and returns them as typed ValidationError values on the left side.

Does this DDD guidance only work with TypeScript?

No, the principles are language-agnostic and apply to any programming language. The code examples use TypeScript with fp-ts for illustration, but concepts like immutability, aggregate roots, and domain services transfer to other languages.