Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use 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.
.claude/skills/hashgraph-online-rust-domain-boundaries/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-22 | ✗→✓ | ▲ Improved | 55% | 0% |
| case-16 | ✓→✓ | = Same ✓ | 5% | 0% |
| case-03 | ✓→✓ | = Same ✓ | -2% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 66% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 5% | 0% |
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.
files, environment variables, database rows, queues, and CLI flags.
serde deserialize incomingshapes, then convert DTO fields into validated domain values.
usernames, passwords, subscriber names, slugs, tenant IDs, idempotency keys, and money-like or duration-like values.
pub fields or impl From<String> for fallible conversions.
leaking internal details.
the final persistence or serialization edge.
lengths, normalization rules, and round trips.
TryFrom<String>, TryFrom<&str>, or FromStr for fallible parsing.AsRef<str> or a named accessor for read-only exposure.Display only when the formatted value is safe to show in logs,errors, and UI.
Debug for secret-bearing values unless the debug output isredacted.
canonicalization.
Deserialize into a request shape, then construct a command:
rust#[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.
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:
serde or SQL mapping when that type crosses thoseboundaries.
references/newtype-patterns.md: constructor, trait, serde, and persistencepatterns for Rust newtypes.
references/property-testing.md: property-testing strategy for parsers anddomain constructors.
Other measured skills in the registry, with their headline benchmark lift.