dotnet-domain-primitives

Enforce strongly typed IDs and value objects in .NET domain models.

1|1|Updated Jan 3, 2026
One-click install
npx skills add https://github.com/mcj-coder/development-skills --skill dotnet-domain-primitives
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-domain-primitives
Source: https://github.com/mcj-coder/development-skills/tree/main/skills/dotnet-domain-primitives
Command: npx skills add https://github.com/mcj-coder/development-skills --skill dotnet-domain-primitives

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents "primitive obsession" in .NET domain models by enforcing the use of strongly typed identifiers and value objects, leading to more robust, type-safe, and maintainable code.

Core Features & Use Cases

  • Strongly Typed IDs: Replaces primitive types like Guid or int for entity identifiers with custom, type-safe ID objects.
  • Value Objects: Encapsulates meaningful primitives (e.g., EmailAddress, Money) with built-in validation and immutability.
  • Boundary Enforcement: Ensures conversions to/from primitive types occur only at explicit boundaries (persistence, transport, serialization).
  • Use Case: When designing a new Order entity, instead of using Guid for OrderId, you define a OrderId strongly typed ID, ensuring it can never be accidentally mixed up with a CustomerId or other Guids.

Quick Start

Use the dotnet-domain-primitives skill to create a strongly typed CustomerId for your domain entities.

Frequently Asked Questions about dotnet-domain-primitives

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

FAQPage Schema
How do I prevent primitive obsession with strongly typed IDs in C#?

Prevent primitive obsession in C# by replacing primitive types like Guid with strongly typed IDs. This enforces type-safe domain models, ensuring identifiers like OrderId are never accidentally mixed up with other Guids.

Why do I need value objects in .NET domain-driven design?

Value objects in .NET domain-driven design encapsulate meaningful primitives like EmailAddress with built-in validation and immutability. They enforce domain integrity by ensuring custom types carry validation rules directly within the domain model.

How do I handle boundary conversions for strongly typed IDs in .NET?

Handle boundary conversions for strongly typed IDs by ensuring conversions to and from primitive types occur only at explicit boundaries. This restricts serialization and persistence layers from corrupting domain model integrity.

Do I need source generators to implement strongly typed IDs in C#?

Source generators are required to implement strongly typed IDs in C# efficiently. They automate the definition and usage of custom types for entity identifiers, reducing boilerplate while enforcing domain primitives.

What is the best way to enforce domain integrity with typed identifiers?

The best way to enforce domain integrity with typed identifiers is automating custom type definitions for entity identifiers and meaningful primitives. This prevents accidental type mixing and pushes validation directly into the domain model.

Can I use value objects for persistence and transport layers in C#?

Value objects in C# are used for persistence and transport layers through explicit boundary conversions. They maintain immutability within the domain while allowing necessary primitive type conversions strictly at serialization boundaries.