domain-layer-expert

Design Rust domain models with value objects, entities, and domain events.

2|1|Updated Oct 31, 2025
One-click install
npx skills add https://github.com/EmilLindfors/claude-marketplace --skill domain-layer-expert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: domain-layer-expert
Source: https://github.com/EmilLindfors/claude-marketplace/tree/main/plugins/rust-hexagonal/skills/domain-layer-expert
Command: npx skills add https://github.com/EmilLindfors/claude-marketplace --skill domain-layer-expert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps designers craft expressive domain models with behavior, value objects, and domain logic instead of anemic data structures.

Core Features & Use Cases

  • Value objects: Encapsulate invariants and validations.
  • Entities with behavior: Domain methods enforcing rules.
  • Domain events: Capture events for downstream processing.

Quick Start

Define a domain model with behavior and separate persistence behind a port or repository.

Frequently Asked Questions about domain-layer-expert

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design rich domain models with behavior in Rust instead of using primitive types?

Rich domain models in Rust encapsulate business logic and validation rules within value objects and entities rather than using raw primitives. This approach prevents primitive obsession, enforces invariants at the type level, and makes domain constraints explicit in your code structure.

What are value objects and how do I implement them in Rust?

Value objects are domain-driven patterns that encapsulate invariants and validations for immutable concepts like money or email addresses. In Rust, implement them as structs with private fields, validation logic in constructors, and derived equality traits to ensure type safety and business rule enforcement.

How do I avoid anemic domain models and add behavior to entities?

Move business logic from services into entity methods that enforce domain rules directly. In Rust, define impl blocks on entities to encapsulate operations, validate state transitions, and emit domain events, keeping behavior co-located with the data it operates on.

What are domain events and when should I use them in Rust?

Domain events capture significant business occurrences within your domain for downstream processing and event sourcing. Emit them from entities during state transitions to enable loose coupling, audit trails, and integration with other systems while maintaining clear separation of concerns.

How do I separate domain logic from persistence in Rust?

Implement repository patterns or ports to abstract persistence behind interfaces. Keep domain entities and value objects free of database concerns, allowing them to focus on business rules while repositories handle serialization and storage, enabling testability and technology independence.

Do domain-driven patterns work with Rust's ownership model?

Yes. Rust's type system naturally enforces domain invariants through ownership, borrowing, and immutability. Value objects leverage these features to make invalid states unrepresentable, and entities use impl methods to guarantee business rules are maintained across state transitions.