domain-entity

Generates DDD domain entities, value objects, and domain events for C# ERP modules.

Updated Aug 18, 2026
One-click install
npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill domain-entity-aurelian1974
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: domain-entity
Source: https://github.com/Aurelian1974/ERPEnterprise/tree/main/.github/skills/domain-entity
Command: npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill domain-entity-aurelian1974

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Domain layer code for an ERP system requires strict consistency: aggregate roots with UUIDv7 identifiers, private setters, factory methods, business invariants, and domain events raised from entities rather than handlers. This Skill generates correct Domain layer code following these rules so the Domain layer stays free of external dependencies. ## Core Features & Use Cases - AggregateRoot and Entity templates: Generates sealed C# classes with private constructors, static factory methods, private setters, and Guard-based invariant enforcement. - ValueObject and DomainEvent templates: Produces equality-by-value objects like Money and InvoiceNumber, plus record-based domain events with EventId and OccurredAt. - Supporting patterns: Includes enum templates mapped to TINYINT, static error classes using the "{module}.{entity}.{code}" format, and Application-layer event handlers that publish integration events via MassTransit. - Use Case: When asked to create an Invoice aggregate for a Finance module, the Skill produces the entity with UUIDv7 ID generation, AddLine/Approve/Cancel business methods, and raised domain events, all with zero Infrastructure references. ## Quick Start Ask the AI to create a new aggregate root entity with value objects and domain events for a specific ERP module using the domain-entity skill.

Frequently Asked Questions about domain-entity

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

FAQPage Schema
How do I create a DDD aggregate root in C#?▼

Create a sealed class inheriting from an AggregateRoot base that holds a domain events list. Use a private constructor, a static factory method with Guard clauses for invariants, private setters, and business-named methods that raise domain events instead of exposing setters.

How to generate UUIDv7 identifiers for SQL Server entities?▼

Generate the ID in C# using Uuid.NewDatabaseFriendly(Database.SqlServer) inside the factory method, so the identifier is available before the INSERT. Child entities can use a temporary Guid.NewGuid() when SQL Server generates a BIGINT IDENTITY at insert time.

Should domain events be raised from entities or handlers?▼

Domain events should be raised from inside the entity when state changes, not from command handlers. The entity collects events via a RaiseDomainEvent method, and Application-layer handlers later transform them into integration events published through MassTransit.

Can the Domain layer reference Infrastructure or NuGet packages?▼

No. The Domain layer must have zero external dependencies: no NuGet packages and no references to Infrastructure or Application. All business invariants live in the entity through Guard clauses, keeping the layer fully isolated and testable.

When should I use a value object instead of an entity?▼

Use a value object for concepts defined by their values rather than identity, such as Money or InvoiceNumber. Value objects implement equality through GetEqualityComponents, are immutable, and validate their inputs in static factory methods.