Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Domain Layer Expert

ASecurity

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.

416 stars
0 votes
0 copies
1 views
Added 2/7/2026
developmentrustgoexpress

Security Analysis

A100/100

Scanned 2/12/2026

Install to Claude Code

$npx -y skills add aiskillstore/marketplace --skill domain-layer-expert --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Domain Layer Expert?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Domain Layer Expert
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aiskillstore-domain-layer-expert/badge)](https://www.skillsdirectory.com/skills/aiskillstore-domain-layer-expert)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: domain-layer-expert
description: 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.
allowed-tools: Read, Grep
version: 1.0.0
---

# 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 != UserStatus::Active {
            return Err(DomainError::UserNotActive);
        }
        self.email = new_email;
        Ok(())
    }

    // Getters
    pub fn id(&self) -> &UserId { &self.id }
    pub fn email(&self) -> &Email { &self.email }
}
```

### Pattern 3: Domain Events

```rust
#[derive(Debug, Clone)]
pub enum UserEvent {
    UserCreated { id: UserId, email: Email },
    UserDeactivated { id: UserId },
    EmailChanged { id: UserId, old_email: Email, new_email: Email },
}

pub struct User {
    id: UserId,
    email: Email,
    events: Vec<UserEvent>,
}

impl User {
    pub fn new(email: Email) -> Self {
        let id = UserId::generate();
        let mut user = Self {
            id: id.clone(),
            email: email.clone(),
            events: vec![],
        };
        user.record_event(UserEvent::UserCreated { id, email });
        user
    }

    pub fn change_email(&mut self, new_email: Email) -> Result<(), DomainError> {
        let old_email = self.email.clone();
        self.email = new_email.clone();
        self.record_event(UserEvent::EmailChanged {
            id: self.id.clone(),
            old_email,
            new_email,
        });
        Ok(())
    }

    pub fn take_events(&mut self) -> Vec<UserEvent> {
        std::mem::take(&mut self.events)
    }

    fn record_event(&mut self, event: UserEvent) {
        self.events.push(event);
    }
}
```

### Pattern 4: Business Rules

```rust
pub struct Order {
    id: OrderId,
    items: Vec<OrderItem>,
    status: OrderStatus,
    total: Money,
}

impl Order {
    pub fn new(items: Vec<OrderItem>) -> Result<Self, DomainError> {
        if items.is_empty() {
            return Err(DomainError::EmptyOrder);
        }

        let total = items.iter().map(|item| item.total()).sum();

        Ok(Self {
            id: OrderId::generate(),
            items,
            status: OrderStatus::Pending,
            total,
        })
    }

    pub fn add_item(&mut self, item: OrderItem) -> Result<(), DomainError> {
        if self.status != OrderStatus::Pending {
            return Err(DomainError::OrderNotEditable);
        }

        self.items.push(item.clone());
        self.total = self.total + item.total();
        Ok(())
    }

    pub fn confirm(&mut self) -> Result<(), DomainError> {
        if self.status != OrderStatus::Pending {
            return Err(DomainError::OrderAlreadyConfirmed);
        }

        if self.total < Money::dollars(10) {
            return Err(DomainError::MinimumOrderNotMet);
        }

        self.status = OrderStatus::Confirmed;
        Ok(())
    }
}
```

## Anti-Patterns to Avoid

### ❌ Primitive Obsession

```rust
// BAD: Using primitives everywhere
pub struct User {
    pub id: String,
    pub email: String,
    pub age: i32,
}

fn create_user(email: String, age: i32) -> User {
    // No validation, easy to pass wrong data
}

// GOOD: Domain types
pub struct User {
    id: UserId,
    email: Email,
    age: Age,
}

impl User {
    pub fn new(email: Email, age: Age) -> Result<Self, DomainError> {
        // Validation already done in Email and Age types
        Ok(Self {
            id: UserId::generate(),
            email,
            age,
        })
    }
}
```

### ❌ Anemic Domain Model

```rust
// BAD: Domain is just data
pub struct User {
    pub id: String,
    pub email: String,
    pub status: String,
}

// Business logic in service layer
impl UserService {
    pub fn deactivate_user(&self, user: &mut User) {
        user.status = "inactive".to_string();
    }
}

// GOOD: Domain has behavior
pub struct User {
    id: UserId,
    email: Email,
    status: UserStatus,
}

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

## Your Approach

When you see domain models:
1. Check for primitive obsession
2. Suggest value objects for domain concepts
3. Move validation into domain types
4. Add behavior methods to entities
5. Ensure immutability where appropriate

Proactively suggest rich domain patterns when you detect anemic models or primitive obsession.

Attribution

aiskillstoreaiskillstore
View sourceMore from aiskillstore →
SSkills DirectorySkills Directory

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Know which skills are safe — weekly.

Best new skills + every skill we flagged as malicious. From the team that scanned 103,619.

Join free

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284722 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2192 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →