domain-entity-typed-ids

Installation
SKILL.md

Domain Entity Typed IDs

Goal

Choose the right level of type distinction for domain entity identifiers based on whether the project's type system is nominal or structural.

In a nominal type system, two types with the same structure are distinct if they have different names. A typed ID — a dedicated type per domain entity wrapping the underlying identifier — provides compile-time safety against mixing identifiers of different entities at no meaningful cost.

In a structural type system, two types with the same structure are interchangeable regardless of their names. A typed ID only provides safety if the language offers a low-friction mechanism to make the types nominally distinct. If achieving nominal distinction requires patterns that add significant boilerplate, ceremony, or ergonomic friction, use the underlying identifier type directly instead.

What Counts as In Scope

Apply this skill to code that does one or more of these things:

  • defines the type of a domain entity's identifier
  • introduces a new domain entity that needs an identifier type
  • changes or refactors how a domain entity's identifier is typed
  • reviews whether an identifier type provides appropriate type safety for the project's type system
Related skills

More from code-sherpas/agent-skills

Installs
6
First Seen
Mar 24, 2026