domain-modeling

Applies tactical Domain-Driven Design patterns to Java microservice domain models.

Updated Jun 25, 2026
One-click install
npx skills add https://github.com/oriddd/ai-toolkit --skill domain-modeling-oriddd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: domain-modeling
Source: https://github.com/oriddd/ai-toolkit/tree/main/copilot/public/skills/domain-modeling
Command: npx skills add https://github.com/oriddd/ai-toolkit --skill domain-modeling-oriddd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Java microservices with non-trivial business logic often degrade into anemic models, leaked abstractions, and unclear consistency boundaries. This Skill provides a shared tactical Domain-Driven Design vocabulary so aggregates, value objects, and domain events are modeled consistently across services. ## Core Features & Use Cases - Aggregate and invariant modeling: Defines Aggregate Roots that encapsulate state, enforce invariants, and register domain events, with one aggregate per transaction. - Value Objects and Domain Events: Uses Java records for identity-free types like Money and DocumentId, plus past-tense event records published via the outbox pattern. - Integration patterns: Covers Anti-Corruption Layers for external systems, Domain Services for cross-aggregate behavior, Repositories returning only roots, and composable Specifications. - Use Case: When adding a new Document aggregate to an existing Spring Boot service, use this Skill to structure the root entity, wrap identifiers in value objects, and emit a DocumentRenamedEvent through the messaging outbox. ## Quick Start Apply the domain-modeling skill to design the aggregate, value objects, and domain events for the new business concept in this service.

Frequently Asked Questions about domain-modeling

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

FAQPage Schema
How do I model an aggregate root in Java with DDD?

Make the aggregate root the only mutation entry point: expose behavior methods that enforce invariants and register domain events, and return immutable views of internal collections. Keep one aggregate per transaction and handle cross-aggregate consistency asynchronously via events.

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

A value object is immutable and identified by its value, not identity, making Java records a natural fit for types like Money or DocumentId. An entity has a distinct identity that persists through state changes and lives inside an aggregate.

When should I use an anti-corruption layer in a microservice?

Use an anti-corruption layer whenever integrating with an external system whose model is incompatible, such as a legacy API or third-party SDK. The ACL translates their concepts into your domain language so foreign models never leak into your aggregates.

When is Domain-Driven Design overkill for a microservice?

Skip aggregate and value-object discipline for pure CRUD services over external data, domains with fewer than five concepts, or small teams on short-lived services. Adopt DDD incrementally only when invariants, workflows, or business rules appear.

Can Spring Data repositories be used with DDD aggregates?

Yes, Spring Data repositories are acceptable as long as their interfaces return aggregate roots only, never inner entities. Repositories should present a collection-like abstraction over aggregates, such as findById and save on the root type.