clean-architecture

Organize .NET applications into four-layer Clean Architecture projects.

224|87|Updated Dec 15, 2018
One-click install
npx skills add https://github.com/Resgrid/Core --skill clean-architecture-resgrid
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-architecture
Source: https://github.com/Resgrid/Core/tree/main/.opencode/skills/clean-architecture
Command: npx skills add https://github.com/Resgrid/Core --skill clean-architecture-resgrid

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Clean Architecture reduces maintainability problems caused by tangled dependencies by enforcing a strict separation between business rules, application use cases, infrastructure concerns, and HTTP delivery.

Core Features & Use Cases

  • Layered project structure: Establish a four-project layout (Domain, Application, Infrastructure, Api) with clear responsibilities and boundaries.
  • Dependency inversion enforcement: Keep the Domain free of framework and external dependencies while the outer layers reference inner abstractions.
  • Use-case-first orchestration: Implement each command and query as a focused Application handler that coordinates domain logic and persistence via abstractions.
  • Infrastructure as a plugin: Swap EF Core, external services, and storage implementations without changing business logic.
  • Thin API endpoints: Map HTTP requests to use cases and return responses without embedding business rules in controllers/handlers.

Quick Start

Load this skill when designing a .NET project that needs a layered architecture, dependency inversion, and use-case handlers aligned to a Clean Architecture style.

Frequently Asked Questions about clean-architecture

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

FAQPage Schema
How do I structure a .NET application to prevent dependency tangling between business rules and infrastructure?

Clean Architecture prevents dependency tangling in .NET by enforcing a four-project layout (Domain, Application, Infrastructure, Api) with strict dependency direction. The Domain layer stays isolated, while outer layers reference inner abstractions to keep business rules testable.

How do I implement command and query use cases in a layered .NET architecture?

You implement command and query use cases as focused Application handlers that coordinate domain logic and persistence via abstractions. This use-case-first orchestration keeps API endpoints thin, mapping HTTP requests to use cases without embedding business rules in controllers.

When do I need clean architecture for my .NET project?

You need clean architecture when building .NET domains with invariants and wanting to swap infrastructure implementations like EF Core or external services. It establishes clear boundaries, allowing you to replace storage implementations without changing core business logic.

What is dependency inversion in clean architecture and how does it keep the domain isolated?

Dependency inversion keeps the Domain free of framework dependencies by having Infrastructure depend on Application and Domain via interfaces. This enforces a strict separation where API endpoints depend only on abstractions, making the domain isolated and testable.

Can I swap EF Core for a different persistence provider without changing business logic in a layered .NET application?

Yes, clean architecture treats infrastructure as a plugin, allowing you to swap EF Core, external services, and storage implementations without changing business logic. The Application layer coordinates persistence via abstractions, decoupling workflows from specific data providers.

Why should API endpoints be thin in clean architecture .NET systems?

API endpoints should be thin to prevent embedding business rules in controllers. Clean architecture maps HTTP requests directly to use case handlers and returns responses, ensuring that API endpoints depend only on abstractions and keeping delivery concerns separate from business workflows.