Domain services

From IntentArchitect/Intent.Modules.NET · View interactive version

Domain services is an AI agent skill from the GitHub repository IntentArchitect/Intent.Modules.NET. guidance for implementing missing c# domain service functionality in clean architecture solutions. use when an ai coding agent must complete methods in domain-level service classes where domain entities live in a separate project with no infrastructure dependencies, service interfaces belong in the

How to use this skill

Skill file

Domain Services Implementation

Purpose

Use this skill to implement missing C# Domain Service methods in a Clean Architecture codebase while keeping the Domain project dependency-free.

A Domain Service here means a domain-level class that expresses business rules that do not belong cleanly inside one Entity or Value Object. It is not an application service, infrastructure service, repository implementation, API handler, or orchestration layer.

Core rules

Implementation workflow

  1. Inspect the Domain Service class, its interface, related entities/value objects, domain exceptions/results, and any existing tests.
  2. Identify each unimplemented method and write down the business invariant it should enforce.
  3. Determine where the logic belongs:
  1. Implement the smallest complete domain-only solution.
  2. Add or update focused unit tests for the business rules and edge cases.
  3. Check that the Domain project still has no new external dependencies.

DI guidance

Use dependency injection only for domain concepts, for example:

public sealed class PricingDomainService : IPricingDomainService
{
    private readonly IDiscountPolicy _discountPolicy;

    public PricingDomainService(IDiscountPolicy discountPolicy)
    {
        _discountPolicy = discountPolicy ?? throw new ArgumentNullException(nameof(discountPolicy));
    }
}

Valid injected dependencies are domain interfaces such as policies, calculators, clocks already abstracted as domain concepts, rule providers, or specifications.

Invalid injected dependencies include DbContext, repositories that hide persistence orchestration for the method, HTTP clients, loggers, application services, mediator, unit of work, configuration, queues, or infrastructure clients.

Coding style

Output expected from the AI coding agent

When completing code, provide:

  1. The implemented Domain Service method(s).
  2. Any minimal domain-only helper types or private helpers needed.
  3. Unit tests or test cases for important business paths.
  4. A brief note if any requested behavior actually belongs outside the Domain layer.

Keep the response focused on code changes, not Clean Architecture theory.

Red flags to call out

Call out the issue before coding when the missing implementation appears to require:

In those cases, suggest a domain interface only if it represents a true domain concept; otherwise keep the behavior in the Application or Infrastructure layer.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.