- Home
- Skills
- Agents & Orchestration
- Domain Modeling: Pragmatic DDD
Works with the AI Agents you already use
Domain Modeling: Pragmatic DDD
Domain modeling is difficult to get right, often leading to a "big ball of mud" where business logic is scattered across controllers and database schemas.
Free
Domain Modeling: Pragmatic DDD
Example session with this skill installed
Help me model a digital library system where users can borrow books and handle late returns.
- Read your context and instructions
- Compiled the domain modeling
I have analyzed the library domain, focusing on the core borrowing lifecycle and the distinction between inventory and cataloging.
Domain Model: Digital Library
Ubiquitous Language
| Term | Meaning | Not to be confused with | Example |
|---|---|---|---|
| Patron | A registered user with borrowing privileges | Staff, Guest | Alice (ID: 456) |
| Exemplar | A physical copy of a book in stock | Book Title | Copy #12 of 'The Hobbit' |
| Loan | The active period a Patron has an Exemplar | Reservation | Loan #89, Due Oct 12 |
Event Storming
`Patron` ->
**BorrowBook** -> `[Loan]` ->
**BookBorrowed** -> `Policy: Update Inventory` ->
**MarkAsUnavailable** -> `[Exemplar]` ->
ExemplarUnavailable
Bounded Contexts
- Lending (Core): Manages loans, returns, and late fees.
- Catalog (Supporting): Metadata about books (titles, authors).
- Inventory (Generic): Tracks physical item locations and status.
Aggregate: Loan
- Root: Loan
- Invariants: A patron cannot borrow more than 5 books; Due date must be in the future.
- Commands:
renew(),returnBook(),applyLateFee(). - Value Objects:
DateRange,Money(for fines).
Implementation Skeleton
// Domain Layer: Loan Aggregate
class Loan {
private constructor(
private readonly id: string,
private readonly patronId: string,
private readonly exemplarId: string,
private period: DateRange
) {}
static create(patron: Patron, exemplar: Exemplar): Loan {
if (!patron.canBorrow()) throw new Error("Borrowing limit reached");
return new Loan(crypto.randomUUID(), patron.id, exemplar.id, DateRange.default());
}
returnBook(actualDate: Date): void {
if (this.period.isOverdue(actualDate)) {
// Emit LoanOverdue event
}
}
}
Next steps
- Define the
FinePolicyfor calculating late fees based on days overdue. - Map the
Loanaggregate to a single database collection to ensure atomic updates. - Establish the Anti-Corruption Layer between Lending and the legacy Catalog API.
Connects securely to your tools. The creator never sees your data.
About this skill
Domain modeling is difficult to get right, often leading to a "big ball of mud" where business logic is scattered across controllers and database schemas. This skill applies pragmatic Domain-Driven Design (DDD) to translate messy requirements into a structured, maintainable architecture before you write a single line of production code.
What it does
- Ubiquitous language construction creates a glossary to resolve synonyms and homonyms across the team.
- Event storming maps the domain timeline from actor commands to events and subsequent policies.
- Bounded context definition groups logic by language and ownership to prevent leaky abstractions.
- Aggregate design identifies root entities and the specific invariants they must protect.
- Visual modeling generates Mermaid diagrams for context maps and class relationships.
- Code mapping provides a skeleton showing how to separate domain logic from framework and database code.
How it works
- Discovery through targeted questions about actors, workflows, and business rules.
- Analysis of terms and events to establish the timeline and bounded contexts.
- Definition of aggregates, entities, and value objects with clear consistency boundaries.
- Implementation via a code skeleton and database strategy tailored to the model.
Frameworks & tools
This skill is language-agnostic but follows hexagonal or clean architecture patterns. It uses Mermaid for diagrams and provides implementation examples for any backend stack including Node.js, Go, Python, or Java.
Why this beats prompting it yourself
Generic prompts often produce shallow CRUD diagrams that ignore business invariants. This skill enforces strict DDD rules, such as referencing aggregates by ID and ensuring value objects are immutable, which prevents architectural technical debt.
Use cases
- Starting a new product module with complex business requirements.
- Refactoring a monolithic codebase where naming is confusing and logic is duplicated.
- Resolving conflicts between stakeholders who use the same word for different concepts.
- Designing a microservices architecture based on logical bounded contexts.
Known limitations
The skill flags where full DDD is overkill and will suggest a simple CRUD approach for trivial domains. Diagrams are constrained to roughly 15 nodes for readability.
Mermaid diagrams are kept under 15 nodes for clarity. It will explicitly suggest skipping DDD for simple CRUD apps to avoid unnecessary boilerplate.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
This skill has been used 7 times.
Trust & safety
Security scan
Security scan passed 7 days ago
- Free with an Agensi account
Permissions
No special permissions declared or detected