domain-service

Installation
SKILL.md

Domain Service

Goal

When domain logic involves multiple aggregates and does not naturally belong to any single one of them, encapsulate that logic in a domain service.

A domain service is a stateless operation expressed in domain terms that enforces business rules spanning multiple aggregates. It receives domain types as input, returns domain types as output, and has no dependencies on infrastructure — no repositories, no transactions, no external systems.

Domain logic that belongs to a single aggregate must stay on that aggregate — in the aggregate root or its child entities. A domain service is only appropriate when no single aggregate can own the logic.

The business-logic entry point (application service) is responsible for loading the aggregates from their repositories, passing them to the domain service, and persisting the results. The domain service never performs these orchestration tasks itself.

What Counts as In Scope

Apply this skill to code that does one or more of these things:

  • implements domain logic that involves entities or data from multiple aggregates
  • places cross-aggregate domain logic directly in a business-logic entry point instead of a domain service
  • places cross-aggregate domain logic on one aggregate where it does not naturally belong
Related skills

More from code-sherpas/agent-skills

Installs
6
First Seen
Mar 24, 2026