# Build Rich Rust Domain Models

Weak domain layers scatter business rules and make validation inconsistent. This skill helps Claude, Codex, and Claude Code design expressive Rust domain models.

## Install

```bash
npx skillstore add emillindfors/domain-layer-expert
```

## Metadata

- Status: approved
- Slug: emillindfors-domain-layer-expert
- Version: 1.0.0
- Author version: 1.0.0
- Skillstore revision: r1
- Version status: valid
- Tree hash: 82043931ab108d2b15a629096ca77ce5acf1393dc02a7665dd426234c9728444
- Author: EmilLindfors
- GitHub username: EmilLindfors
- License: MIT
- Repository: https://github.com/EmilLindfors/claude-marketplace/tree/main/plugins/rust-hexagonal/skills/domain-layer-expert
- Ref: a06681402992ceae98ba04d54cfd4ab004862696
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands
- Quality score: 80
- Quality tier: silver
- Public page: https://skillstore.pages.dev/skills/emillindfors-domain-layer-expert
- Manifest: https://skillstore.pages.dev/api/skills/emillindfors-domain-layer-expert/manifest

## Capabilities

- Identifies primitive obsession in Rust domain types.
- Suggests value objects with validation constructors.
- Moves business rules into entities and aggregates.
- Models domain events for important state changes.
- Highlights anemic domain models and service-heavy logic.

## Use Cases

- Refactor Primitive Models: Convert string-heavy entities into validated value objects and clearer domain types.
- Design Business Rules: Place validation, state changes, and invariants inside entities instead of services.
- Review Domain Architecture: Check whether a Rust domain layer follows hexagonal architecture and domain-driven design principles.

## Prompt Templates

### Find Domain Smells

```
Review this Rust domain model for primitive obsession and anemic design. Suggest the first three improvements.
```

### Create Value Objects

```
Help me turn these domain fields into Rust value objects with validation, clear errors, and ergonomic constructors.
```

### Move Rules Into Entities

```
Refactor this service-heavy workflow so the Rust entities own the state transitions and business invariants.
```

### Model Events and Aggregates

```
Design aggregates and domain events for this Rust bounded context. Explain entity boundaries, invariants, and event publication points.
```

## Limitations

- Focuses on Rust domain layer design, not database or UI code.
- Provides patterns and examples, not complete application architecture.
- Cannot prove business rules are correct without domain context.
- Does not run tests or inspect files beyond allowed read tools.

## Best Practices

- Provide real domain rules and examples before asking for a redesign.
- Ask for small refactors first when a model has many responsibilities.
- Review generated patterns against product language and business constraints.

## Anti Patterns

- Do not ask it to design persistence models as if they were domain entities.
- Do not accept generated business rules without stakeholder validation.
- Do not mix infrastructure concerns into value object and entity design.

## Security Audit

- Audited at: 2026-07-06T14:44:06.8\+00:00
- Summary: All static findings are false positives from Markdown fences, Rust sample identifiers, and a front matter heuristic mismatch. No evidence found for command execution, prompt injection, data exfiltration, network access, or filesystem access.

## Stats

- Views: 150
- Downloads: 11
- Favorites: 0
- Popularity score: 0
