clean-architecture

Enforce four-layer separation and dependency inversion in .NET projects.

4|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill clean-architecture-faysilalshareef
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-architecture
Source: https://github.com/FaysilAlshareef/dotnet-ai-kit/tree/main/skills/architecture/clean-architecture
Command: npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill clean-architecture-faysilalshareef

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides concrete rules, project layout, and practical patterns to prevent architecture erosion in .NET solutions by keeping domain logic free of infrastructure concerns and ensuring dependency inversion across layers.

Core Features & Use Cases

  • Layered project layout: guidance for Domain, Application, Infrastructure, and WebApi projects and their expected contents.
  • Dependency rules & DI guidance: clear rules for project references, interface placement, and composition root responsibilities.
  • Patterns, anti-patterns & migration steps: example implementations, validators, and a decision guide to refactor existing codebases to Clean Architecture.

Quick Start

Use the clean-architecture skill to review a .NET solution and produce a prioritized migration checklist to separate Domain, Application, Infrastructure, and WebApi layers.

Frequently Asked Questions about clean-architecture

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

FAQPage Schema
How do I enforce Clean Architecture in a .NET solution to prevent architecture erosion?

Enforce Clean Architecture in .NET by applying four-layer separation across Domain, Application, Infrastructure, and WebApi projects, verifying project references and dependency inversion to keep domain logic free of infrastructure concerns.

What is the correct project layout for a four-layer Clean Architecture .NET application?

The correct Clean Architecture project layout separates Domain, Application, Infrastructure, and WebApi projects, with the WebApi serving as the DI composition root and Infrastructure implementing repository interfaces defined in the domain.

How do I refactor an existing .NET codebase to Clean Architecture and migrate code between layers?

Refactor an existing .NET codebase to Clean Architecture by generating a prioritized migration checklist, moving code between Domain, Application, Infrastructure, and Presentation layers using provided patterns, anti-patterns, and decision guides.

Where should dependency injection composition be placed in a layered .NET Clean Architecture project?

Dependency injection composition belongs in the WebApi project, acting as the composition root that wires up interface-driven infrastructure implementations while maintaining zero domain dependencies and dependency inversion across layers.

Can I use Clean Architecture with domain-driven design in .NET without adding domain dependencies?

Yes, Clean Architecture supports domain-driven design in .NET by enforcing zero domain dependencies, ensuring repositories use interfaces placed outside infrastructure, and keeping the domain layer pure through consistent project naming and reference rules.

What are the limitations of applying four-layer Clean Architecture to an existing .NET solution?

Applying four-layer Clean Architecture to an existing .NET solution requires strict adherence to interface-driven infrastructure and consistent project naming, which may demand significant refactoring effort to move code and verify DI composition.