clean-architecture-dotnet

Scaffold a Clean Architecture CQRS .NET project with ArchUnit validation.

192|32|Updated May 20, 2025
One-click install
npx skills add https://github.com/SebastienDegodez/copilot-instructions --skill clean-architecture-dotnet
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-architecture-dotnet
Source: https://github.com/SebastienDegodez/copilot-instructions/tree/main/plugins/csharp-clean-architecture-development/skills/clean-architecture-dotnet
Command: npx skills add https://github.com/SebastienDegodez/copilot-instructions --skill clean-architecture-dotnet

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill guides and scaffolds a complete Clean Architecture CQRS setup in .NET, enabling teams to implement CQRS without MediatR, enforce DDD boundaries, and validate architecture with ArchUnit tests from day one.

Core Features & Use Cases

  • Four-layer bootstrap: Domain, Application, Infrastructure, and API project skeletons wired by convention.
  • Convention-based DI: API injects ICommandHandler<> / IQueryHandler<> while Infrastructure registers handlers by name.
  • Architecture validation templates: ArchUnit test templates and marker interfaces to enforce layering rules.
  • Bootstrapping scripts: Included init-project.ps1 and init-project.sh to scaffold a ready-to-run solution.

Quick Start

Run the included init-project script with your project name to bootstrap the structure.

Frequently Asked Questions about clean-architecture-dotnet

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

FAQPage Schema
How do I scaffold a Clean Architecture .NET project with CQRS without MediatR?

To scaffold a Clean Architecture .NET project without MediatR, run the included init-project.ps1 or init-project.sh script. This bootstraps a complete four-layer CQRS solution using marker interfaces like ICommandHandler and IQueryHandler for convention-based wiring.

What is the best way to enforce Domain-Driven Design boundaries in a new .NET application?

Enforcing Domain-Driven Design boundaries in .NET is achieved by scaffolding strict Domain, Application, Infrastructure, and API layers. This setup uses ArchUnit test templates and marker interfaces to validate architectural rules and prevent cross-layer dependencies from day one.

Can I use ArchUnit to validate layered architecture rules in a .NET greenfield project?

Yes, you can validate layered architecture in a .NET greenfield project using ArchUnit. This setup provides ArchUnit test templates and marker interfaces that automatically enforce layering rules and dependency directions across the Domain, Application, Infrastructure, and API layers.

How do I set up convention-based dependency injection for CQRS handlers in .NET?

Convention-based dependency injection for CQRS in .NET is set up by having the API layer inject ICommandHandler and IQueryHandler interfaces. The Infrastructure layer then automatically registers these handlers by name, eliminating manual DI configuration.

Does this Clean Architecture scaffolding support existing .NET codebases or only greenfield projects?

This Clean Architecture scaffolding is designed specifically for greenfield .NET projects. It applies a strict four-layer Domain-Driven Design structure with CQRS without MediatR, which is difficult to retrofit into existing codebases with established dependencies.

Why implement CQRS in .NET without relying on MediatR?

Implementing CQRS without MediatR in .NET uses custom marker interfaces like ICommandHandler and IQueryHandler for direct convention-based dependency injection. This approach provides full control over handler wiring and reduces external library dependencies within your Application layer.