immutable-domain-entities

Installation
SKILL.md

Immutable Domain Entities

Goal

Apply the immutable design pattern when writing or changing domain entities.

An immutable domain entity keeps the same domain identity while preventing in-place mutation of its state. Domain operations that would otherwise change the entity must instead return a new entity instance, or the closest immutable equivalent the stack supports, preserving the same identity and enforcing the same invariants.

Treat this skill as construction and change-management guidance for domain entities. The key question is whether the entity can be modeled so its state is fixed after creation and all valid changes are expressed as explicit creation of a new immutable version.

What Counts as In Scope

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

  • defines a domain entity's fields, properties, or constructor
  • defines domain operations that would change a domain entity's state
  • exposes getters, setters, collections, or nested objects on a domain entity
  • loads, reconstructs, or rehydrates domain entities from persistence or transport data
  • copies, clones, replaces, or updates domain entity instances
Related skills

More from code-sherpas/agent-skills

Installs
8
First Seen
Mar 24, 2026