Rust Domain Boundaries
SkillDev toolsUse when modeling, validating, refactoring, or reviewing Rust service domain boundaries, especially when replacing primitive String fields with newtypes, parse-don't-validate constructors, private invariants, TryFrom/FromStr parsers, request DTO boundaries, or property tests.
Use Rust Domain Boundaries in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Rust Domain Boundaries and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Rust Domain Boundaries skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by hashgraph-online/awesome-codex-plugins in plugins/LVTD-LLC/skills/skills/rust-domain-boundaries/SKILL.md and read by Ahel’s review.
Use this skill to keep invalid states out of Rust service internals. Parse raw input once at the boundary, store validated values in narrow domain types, and make unchecked construction difficult.
Core Workflow
- Find raw input boundaries: HTTP payloads, path/query parameters, config files, environment variables, database rows, queues, and CLI flags.
- Separate transport DTOs from domain types. Let
serdedeserialize incoming shapes, then convert DTO fields into validated domain values. - Replace primitive strings with small types for ruled values: email addresses, usernames, passwords, subscriber names, slugs, tenant IDs, idempotency keys, and money-like or duration-like values.
- Give domain types private fields and smart constructors. Avoid unchecked
pubfields orimpl From<String>for fallible conversions. - Return typed validation errors that map to useful HTTP responses without leaking internal details.
- Keep database and external API mapping explicit. Convert to raw strings at the final persistence or serialization edge.
- Test invariants directly. Cover valid examples, malformed inputs, boundary lengths, normalization rules, and round trips.
Type Design Rules
- Prefer
TryFrom<String>,TryFrom<&str>, orFromStrfor fallible parsing. - Keep stored values owned unless profiling proves borrowing is necessary.
- Implement
AsRef<str>or a named accessor for read-only exposure. - Implement
Displayonly when the formatted value is safe to show in logs, errors, and UI. - Avoid deriving
Debugfor secret-bearing values unless the debug output is redacted. - Make normalization visible in tests: trim, lowercase, Unicode handling, and canonicalization.
Request Boundary Pattern
Deserialize into a request shape, then construct a command:
#[derive(serde::Deserialize)]
pub struct SubscribeRequest {
email: String,
name: String,
}
pub struct SubscribeCommand {
pub email: EmailAddress,
pub name: SubscriberName,
}
impl TryFrom<SubscribeRequest> for SubscribeCommand {
type Error = SubscribeValidationError;
fn try_from(value: SubscribeRequest) -> Result<Self, Self::Error> {
Ok(Self {
email: EmailAddress::parse(value.email)?,
name: SubscriberName::parse(value.name)?,
})
}
}
Handlers should reject invalid input before business logic or database code. If validation needs database state, keep pure parsing separate from uniqueness or authorization checks.
Tests
Read references/property-testing.md when invariants have many edge cases or
when an AI agent is likely to miss invalid inputs with example-only tests.
Minimum tests for a new domain type:
- Accept a realistic valid value.
- Reject empty input and whitespace-only input.
- Reject too-long input when storage or product rules impose limits.
- Reject format violations.
- Preserve or normalize exactly as documented by tests.
- Round-trip through
serdeor SQL mapping when that type crosses those boundaries.
Reference Files
references/newtype-patterns.md: constructor, trait, serde, and persistence patterns for Rust newtypes.references/property-testing.md: property-testing strategy for parsers and domain constructors.
Signals
- GitHub stars
- 1k
- Forks
- 316
- Last commit
- Oct 2026
Advanced
- Item type
- skill
- Key
rust-domain-boundaries- Source
- github.com/hashgraph-online/awesome-codex-plugins
github.com/hashgraph-online/awesome-codex-plugins