skills/emillindfors/domain-layer-expert/SKILL.md
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.
npx skillsauth add aiskillstore/marketplace domain-layer-expertInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
Activate when you notice:
// ✅ 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)
}
}
#[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 }
}
#[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);
}
}
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(())
}
}
// 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,
})
}
}
// 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(())
}
}
When you see domain models:
Proactively suggest rich domain patterns when you detect anemic models or primitive obsession.
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.