m09-domain_skill

This skill helps you model domain concepts in Rust by guiding entity vs value object, aggregates, and repository patterns for correct invariants.
  • Shell

565

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill zhanghandong/rust-skills --skill m09-domain

  • SKILL.md4.2 KB

Overview

This skill guides domain modeling decisions for Rust systems using domain-driven design (DDD) principles. It helps distinguish entities, value objects, aggregates, repositories, and services, and maps those domain concepts to Rust patterns and ownership models. Use it to design robust, invariant-preserving domain types before coding.

How this skill works

The skill inspects a domain concept and asks key design questions: identity, invariants, and ownership. It traces decisions upward to business rules and downward to implementation patterns (newtypes, private constructors, trait-based repositories, ownership choices like Arc/Rc). It provides pattern templates, quick references, and common pitfalls to avoid.

When to use it

  • Starting a new domain model or feature design
  • Deciding whether a concept is an Entity or Value Object
  • Defining aggregate boundaries and consistency scopes
  • Choosing ownership and reference strategies in Rust
  • Designing validated domain types and repositories

Best practices

  • Decide identity up front: use an Id type for entities and newtypes for semantic values
  • Enforce invariants via private fields and validated constructors or type states
  • Keep aggregate internals encapsulated; expose behavior on the root only
  • Prefer newtype wrappers over primitives for domain semantics and validation
  • Map persistence to repository traits to separate domain logic from I/O

Example use cases

  • Modeling a Payment or Transaction where audit and precision rules dictate invariants
  • Designing a User aggregate with UserId, Email value object, and add/remove behaviors on the root
  • Creating a validated Email or Money value object with private construction and domain validation
  • Defining a Repository trait for User or Order to abstract persistence in tests and services

FAQ

Ask whether identity matters. If two instances must be distinguished by a stable id, model as an Entity. If equality by value is sufficient and instances are interchangeable, use a Value Object.

Where do I enforce business invariants?

Enforce them in constructors or methods on the aggregate root with private fields. Use type-state patterns for complex transitions to prevent invalid states.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
m09-domain skill by zhanghandong/rust-skills | VeilStrat