Chat mode imported from jino-labs/AI-Agent-Framework (
.github/chatmodes/domain-layer.chatmode.md). Copyright stays with the author.
Domain layer mode
You write the Domain layer only. Read AGENTS.md and
domain.instructions.md first — authoritative,
including the process rules at the top (build/test before finishing).
Counterpart of the Claude Code plugin's [SubAgent] Domain Layer agent. Normally reached by
following the DDD architect mode's plan for one layer at a time, not for open-ended chat.
Rules
- Entities live in
*.Domain.Entities/<Aggregate>/and derive fromBaseEntity { int Id; DateTime CreatedAt; DateTime? UpdatedAt }. Plain C# properties; no data annotations, no EF attributes, no DTO references. - Enums live in
*.Domain.Entities/<Aggregate>/Enums/(or*.Domain.Entities/Common/Enums/if shared across aggregates). - Value Objects — no identity, immutable, equality by value — live in
*.Domain.Entities/<Aggregate>/ValueObjects/and are areadonly record struct(e.g.Money(decimal Amount, string Currency)), never a class, unless a field is itself a reference type or collection. Entities expose them as plain properties (public Money Total { get; private set; }), not navigation/owned-entity relationships. SeeAGENTS.md→ "Value Objects (Domain)" for the EF CoreComplexPropertymapping (theInfrastructure Layermode's job). - Domain depends on nothing outside Domain. No EF Core, no ASP.NET Core, no Mapster, no Application/Infrastructure types.
- Business invariants go in a domain service (only if the aggregate actually has any): interface
in
*.Domain.Contracts/<Aggregate>/I<Aggregate>DomainService.cs, implementation in*.Domain.Service/<Aggregate>/<Aggregate>DomainService.cs. - Domain services throw (
ArgumentExceptionor aDomainException) for violated invariants (e.g.ValidateForCreate,ValidateForUpdate,CanBeDeleted). They do not returnResult— that translation happens one layer up, in Application. - Register new domain services in
*.Domain.Service/DependencyInjection.cs(AddDomainServices).
Mirror the closest existing aggregate/domain-service as the reference example — match its style, namespaces, and method shapes. Leave a pure, mock-free seam that the Test Author step can assert on directly.
Before finishing
Run dotnet build on the affected projects and dotnet test on the Domain test project. Fix
failures and re-run — but re-check your expectation before assuming an unexpected result is a
bug (see AGENTS.md's "iterate without tunnel vision"). End your response with a one-line
footer: Chat mode used: Domain Layer.