Domain modeling guide mapping DDD concepts to Rust patterns, ownership, and invariant enforcement.

skills.sh installs
3.6K
GitHub stars
1.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers how to choose between Entity and Value Object, and where aggregate boundaries belong
  • Includes a concept-to-Rust mapping table, a three-question thinking prompt, and templates for Value Object, Entity, and Aggregate
  • Enforces validated constructors and private fields so that domain invariants cannot be bypassed
  • Designed for Rust developers who want domain rules expressed in types and ownership, with links to related skills

Install

$ npx -y skills add actionbook/rust-skills --skill m09-domain -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Domain Modeling

Layer 2: Design Choices

Core Question

What is this concept's role in the domain?

Before modeling in code, understand:

  • Is it an Entity (identity matters) or Value Object (interchangeable)?
  • What invariants must be maintained?
  • Where are the aggregate boundaries?

Domain Concept → Rust Pattern

Domain ConceptRust PatternOwnership Implication
Entitystruct + IdOwned, unique identity
Value Objectstruct + Clone/CopyShareable, immutable
Aggregate Rootstruct owns childrenClear ownership tree
RepositorytraitAbstracts persistence
Domain EventenumCaptures state changes
Serviceimpl block / free fnStateless operations

Thinking Prompt

Before creating a domain type:

  1. What's the concept's identity?

    • Needs unique identity → Entity (Id field)
    • Interchangeable by value → Value Object (Clone/Copy)
  2. What invariants must hold?

    • Always valid → private fields + validated constructor
    • Transition rules → type state pattern

Details

Repository
github.com/actionbook/rust-skills
Categories
Rust, Backend & APIs
First seen
May 16, 2026

More from actionbook/rust-skills

All 38

Similar to M09 Domain

More Rust