clean-architecture-rules

Enforces Clean Architecture dependency rules across Domain, Application, Persistence, and API layers.

7|3|Updated Sep 23, 2025
One-click install
npx skills add https://github.com/islamu-ngo/Event --skill clean-architecture-rules-islamu-ngo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: clean-architecture-rules
Source: https://github.com/islamu-ngo/Event/tree/main/.agents/skills/clean-architecture-rules
Command: npx skills add https://github.com/islamu-ngo/Event --skill clean-architecture-rules-islamu-ngo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Cross-layer refactors in a .NET Clean Architecture codebase often introduce upward dependencies, misplaced validation, or layer leakage that silently violate the repository contract. This Skill blocks those violations by loading the dependency rules, layer responsibilities, and fix patterns before any architectural change is made. ## Core Features & Use Cases - Dependency Direction Enforcement: Verifies Domain has no external references, Application references Domain only, and Persistence/Infrastructure never leak into inner layers. - Layer Placement Guidance: Decides whether code belongs in Domain, Application, Persistence, Infrastructure, API, or Blazor using decision guides and violation examples. - Record/Class Migration Rules: Governs record class, sealed record, and readonly record struct selection during value-object migrations. - Use Case: When adding a new MediatR handler that needs database access, the Skill ensures the handler depends on a repository interface in Application rather than injecting DbContext directly. ## Quick Start Ask the assistant to review whether a new service or repository belongs in Domain, Application, Persistence, or API before writing the code.

Frequently Asked Questions about clean-architecture-rules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce Clean Architecture dependency rules in .NET?▼

Define allowed references per layer: Domain references nothing, Application references Domain only, and Persistence references Application plus Domain. Verify compliance with architecture tests such as DomainDependencyTests and ApplicationDependencyTests run via dotnet test.

Where should business logic go in Clean Architecture?▼

Business rules and entities belong in the Domain layer, while use cases, commands, queries, handlers, DTOs, and validators belong in Application. HTTP and UI concerns stay in API or Blazor, and database access stays in Persistence behind repository interfaces.

Can the Application layer use DbContext directly?▼

No, Application must depend on repository interfaces, not DbContext. The repository implementation lives in Persistence, and repositories return entities rather than DTOs or IQueryable.

Should Domain entities use DataAnnotations validation?▼

No, Domain must remain free of validation frameworks. Use FluentValidation validators in the Application layer instead; Domain may only use the ForeignKey attribute as a narrow exception.

When should I use a record versus a class in .NET Domain code?▼

Entities and lifecycle objects remain classes, small self-contained values may use readonly record struct, and reference-bearing immutable value data may use sealed records. Choose based on identity and behavior, not a layer-wide conversion rule.