← ClaudeAtlas

hex-domain-servicelisted

Use when a domain rule needs state one entity cannot see — a cross-aggregate check, a uniqueness check, does the referenced Bar exist — producing one stateless domain service (`FooUniquenessService`) with injected protocols and `assert_*`, `is_*` or verb methods. Not an entity invariant and not a tunable threshold, both `hex-domain-model`; orchestrating a use case is `hex-application`.
wntic/pyhouse · ★ 3 · AI & Automation · score 79
Install: claude install-skill wntic/pyhouse
# Hex — Domain Service Produces one domain service: a stateless class that orchestrates a domain rule using injected protocols. Domain services live next to the aggregate they primarily concern. See `naming` for identifiers. ## When to use vs. neighbours - Rule enforceable from one entity's own fields → not a service; use `__post_init__` on the entity (see `hex-domain-model`). - Rule needs to query other aggregates or a domain capability → this skill. - Rule is a numeric or boolean threshold (max rows, retention days, quotas) → not a service; model it as the tunable value object in `hex-domain-model`. - Orchestrating a use case across multiple aggregates → that is a command or query handler, not a service (see `hex-application`). - The `IFooRepository` or `ICan<Verb>` protocols this service takes in its constructor → `hex-domain-ports`. - The exception an `assert_*` method raises → `exception-catalog`. - Binding the service (per-operation) so handlers receive it → `hex-wiring`. - Testing it with stdlib, `pytest` and the domain package alone → `hex-test-domain`. - What the service, its methods and its module are called → `naming`. ## Template — stdlib only, collaborators injected as domain ports ```python from ..exceptions import FooConflictError from .i_foo_repository import IFooRepository __all__ = ["FooUniquenessService"] class FooUniquenessService: def __init__(self, repository: IFooRepository) -> None: self._repository = repository async def asser