Domain Entity UUIDv4 IDs
Goal
Represent domain entity identifiers with UUIDv4.
When the programming language or standard library provides a built-in UUID type, prefer that type for domain entity IDs. When no such built-in type exists, use string for domain entity IDs and keep UUIDv4 generation and validation explicit.
Treat this skill as identity-format guidance for domain entities. It determines the identifier format (UUIDv4) and the underlying type (built-in UUID or string). Whether to wrap that underlying type in a distinct type per domain entity — such as OrderId or CustomerId — is a separate concern handled by the domain-entity-typed-ids skill.
The key question is whether the edited code defines, carries, validates, stores, serializes, or exposes the identifier of a domain entity.
What Counts as In Scope
Apply this skill to code that does one or more of these things:
- defines the ID field or property of a domain entity
- defines constructor parameters or factory inputs for domain entity identity
- defines the type used to carry a domain entity ID through the domain model
- parses, validates, serializes, or deserializes domain entity IDs
- maps domain entity IDs to persistence, transport, or integration boundaries
- creates new domain entity IDs
- compares or stores identity values used to distinguish one entity from another
UUIDv4 Rule
Use UUIDv4 for every domain entity identifier touched by the task.
- Preserve UUIDv4 semantics across in-memory representation, persistence mappings, and exchanged payloads.
- Do not weaken the identifier representation to an unconstrained string when a built-in UUID type exists.
Prefer the language's built-in UUID type when available.
- Use the native or standard-library UUID type directly when the language makes it available and the project conventions allow it.
- Do not fall back to
string when a built-in UUID type exists.
When no built-in UUID type exists, use string.
- Use
string as the underlying identifier type.
- Keep generation, parsing, and validation explicit enough that UUIDv4 remains the enforced format.
- This rule determines the underlying type only. Whether to wrap it in a typed ID such as
OrderId is determined by the domain-entity-typed-ids skill.
Detection Workflow
Find the identity boundary first.
- Locate the fields, properties, constructor arguments, factory inputs, or persistence mappings that represent domain entity identity.
- Check whether the identifier appears in domain code, serialization code, persistence code, or communication contracts.
Detect UUID type support in the stack.
- Identify whether the language or standard library offers a UUID type.
- Follow the project's established conventions for importing, constructing, and storing that type.
Trace generation and conversion points.
- Identify where new IDs are created.
- Identify where IDs are parsed from text, converted for storage, or emitted across boundaries.
- Verify that UUIDv4 remains the enforced format at each point.
Writing or Changing Domain Entity IDs
Keep UUIDv4 explicit in the model.
- Name ID fields and parameters clearly.
- Use the built-in UUID type when available, otherwise use
string.
Prefer native UUID handling over ad hoc strings.
- Use the built-in UUID type when available instead of representing IDs as generic text.
- Keep conversions at boundaries small and explicit.
Use string when the language has no built-in UUID type.
- Keep the UUIDv4 contract explicit at parsing, validation, serialization, and generation points.
- This determines the underlying type. Whether to wrap it in a typed ID is a separate concern.
Preserve identity consistency end to end.
- Verify that the same UUIDv4 value can move through constructors, domain methods, persistence mappings, serializers, and external contracts without losing meaning.
- Verify that new IDs are generated as UUIDv4, not merely accepted in that format.
Keep validation close to parsing or construction.
- Reject malformed or non-UUIDv4 inputs when IDs enter the system as text or external data.
- Make the valid construction path obvious in the code.
Review Questions
When reading or reviewing code, ask:
- Is this code defining or carrying the identity of a domain entity?
- Is that identity represented as UUIDv4?
- Does the stack provide a built-in UUID type that should be used here?
- If not, is the identity represented as
string with explicit UUIDv4 handling?
- Where is UUIDv4 generated, parsed, validated, stored, or serialized?
- Would changing this code risk weakening the UUIDv4 guarantee for domain entity identity?
If the answer is yes, apply this skill.
Report the Outcome
When finishing the task:
- state which domain entity IDs were identified or changed
- state whether a built-in UUID type or
string was used, and why
- state where UUIDv4 generation, parsing, validation, or conversion was implemented or preserved
1---2name: domain-entity-uuidv4-ids3description: Require UUIDv4 identifiers for domain entities. Use when an agent needs to create, modify, review, or interpret domain entity ID fields, ID types, constructors, persistence mappings, serialization, or API contracts tied to domain entity identity. Prefer the programming language's built-in UUID type when it exists. If the language has no built-in UUID type, use `string` while preserving explicit UUIDv4 generation and validation semantics.4---56# Domain Entity UUIDv4 IDs78## Goal910Represent domain entity identifiers with UUIDv4.1112When the programming language or standard library provides a built-in UUID type, prefer that type for domain entity IDs. When no such built-in type exists, use `string` for domain entity IDs and keep UUIDv4 generation and validation explicit.1314Treat this skill as identity-format guidance for domain entities. It determines the identifier format (UUIDv4) and the underlying type (built-in UUID or `string`). Whether to wrap that underlying type in a distinct type per domain entity — such as `OrderId` or `CustomerId` — is a separate concern handled by the `domain-entity-typed-ids` skill.1516The key question is whether the edited code defines, carries, validates, stores, serializes, or exposes the identifier of a domain entity.1718## What Counts as In Scope1920Apply this skill to code that does one or more of these things:2122- defines the ID field or property of a domain entity23- defines constructor parameters or factory inputs for domain entity identity24- defines the type used to carry a domain entity ID through the domain model25- parses, validates, serializes, or deserializes domain entity IDs26- maps domain entity IDs to persistence, transport, or integration boundaries27- creates new domain entity IDs28- compares or stores identity values used to distinguish one entity from another2930## UUIDv4 Rule31321. Use UUIDv4 for every domain entity identifier touched by the task.33 - Preserve UUIDv4 semantics across in-memory representation, persistence mappings, and exchanged payloads.34 - Do not weaken the identifier representation to an unconstrained string when a built-in UUID type exists.35362. Prefer the language's built-in UUID type when available.37 - Use the native or standard-library UUID type directly when the language makes it available and the project conventions allow it.38 - Do not fall back to `string` when a built-in UUID type exists.39403. When no built-in UUID type exists, use `string`.41 - Use `string` as the underlying identifier type.42 - Keep generation, parsing, and validation explicit enough that UUIDv4 remains the enforced format.43 - This rule determines the underlying type only. Whether to wrap it in a typed ID such as `OrderId` is determined by the `domain-entity-typed-ids` skill.4445## Detection Workflow46471. Find the identity boundary first.48 - Locate the fields, properties, constructor arguments, factory inputs, or persistence mappings that represent domain entity identity.49 - Check whether the identifier appears in domain code, serialization code, persistence code, or communication contracts.50512. Detect UUID type support in the stack.52 - Identify whether the language or standard library offers a UUID type.53 - Follow the project's established conventions for importing, constructing, and storing that type.54553. Trace generation and conversion points.56 - Identify where new IDs are created.57 - Identify where IDs are parsed from text, converted for storage, or emitted across boundaries.58 - Verify that UUIDv4 remains the enforced format at each point.5960## Writing or Changing Domain Entity IDs61621. Keep UUIDv4 explicit in the model.63 - Name ID fields and parameters clearly.64 - Use the built-in UUID type when available, otherwise use `string`.65662. Prefer native UUID handling over ad hoc strings.67 - Use the built-in UUID type when available instead of representing IDs as generic text.68 - Keep conversions at boundaries small and explicit.69703. Use `string` when the language has no built-in UUID type.71 - Keep the UUIDv4 contract explicit at parsing, validation, serialization, and generation points.72 - This determines the underlying type. Whether to wrap it in a typed ID is a separate concern.73744. Preserve identity consistency end to end.75 - Verify that the same UUIDv4 value can move through constructors, domain methods, persistence mappings, serializers, and external contracts without losing meaning.76 - Verify that new IDs are generated as UUIDv4, not merely accepted in that format.77785. Keep validation close to parsing or construction.79 - Reject malformed or non-UUIDv4 inputs when IDs enter the system as text or external data.80 - Make the valid construction path obvious in the code.8182## Review Questions8384When reading or reviewing code, ask:8586- Is this code defining or carrying the identity of a domain entity?87- Is that identity represented as UUIDv4?88- Does the stack provide a built-in UUID type that should be used here?89- If not, is the identity represented as `string` with explicit UUIDv4 handling?90- Where is UUIDv4 generated, parsed, validated, stored, or serialized?91- Would changing this code risk weakening the UUIDv4 guarantee for domain entity identity?9293If the answer is yes, apply this skill.9495## Report the Outcome9697When finishing the task:9899- state which domain entity IDs were identified or changed100- state whether a built-in UUID type or `string` was used, and why101- state where UUIDv4 generation, parsing, validation, or conversion was implemented or preserved