Back to Skills

domain-layer-expert

verified

Guides users in creating rich domain models with behavior, value objects, and domain logic. Activates when users define domain entities, business rules, or validation logic.

View on GitHub

Marketplace

lf-marketplace

EmilLindfors/claude-marketplace

Plugin

rust-hexagonal

development

Repository

EmilLindfors/claude-marketplace
2stars

plugins/rust-hexagonal/skills/domain-layer-expert/SKILL.md

Last Verified

January 20, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/EmilLindfors/claude-marketplace/blob/main/plugins/rust-hexagonal/skills/domain-layer-expert/SKILL.md -a claude-code --skill domain-layer-expert

Installation paths:

Claude
.claude/skills/domain-layer-expert/
Powered by add-skill CLI

Instructions

# Domain Layer Expert Skill

You are an expert at designing rich domain models in Rust. When you detect domain entities or business logic, proactively suggest patterns for creating expressive, type-safe domain models.

## When to Activate

Activate when you notice:
- Entity or value object definitions
- Business validation logic
- Domain rules implementation
- Anemic domain models (just data, no behavior)
- Primitive obsession (using String/i64 for domain concepts)

## Domain Model Patterns

### Pattern 1: Value Objects

```rust
// ✅ Value object with validation
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Email(String);

impl Email {
    pub fn new(email: String) -> Result<Self, ValidationError> {
        if !email.contains('@') {
            return Err(ValidationError::InvalidEmail("Missing @ symbol".into()));
        }
        if email.len() > 255 {
            return Err(ValidationError::InvalidEmail("Too long".into()));
        }
        Ok(Self(email))
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

// Implement TryFrom for ergonomics
impl TryFrom<String> for Email {
    type Error = ValidationError;

    fn try_from(s: String) -> Result<Self, Self::Error> {
        Self::new(s)
    }
}
```

### Pattern 2: Entity with Identity

```rust
#[derive(Debug, Clone)]
pub struct User {
    id: UserId,
    email: Email,
    name: String,
    status: UserStatus,
}

impl User {
    pub fn new(email: Email, name: String) -> Self {
        Self {
            id: UserId::generate(),
            email,
            name,
            status: UserStatus::Active,
        }
    }

    // Domain behavior
    pub fn deactivate(&mut self) -> Result<(), DomainError> {
        if self.status == UserStatus::Deleted {
            return Err(DomainError::UserAlreadyDeleted);
        }
        self.status = UserStatus::Inactive;
        Ok(())
    }

    pub fn change_email(&mut self, new_email: Email) -> Result<(), DomainError> {
        if self.status != UserStatu

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5205 chars