CleanArchitecture
Copilot instructions19k starsChanged 6 years agoMITView on GitHub
We split this copilot-instructions.md into the rules it gives an agent
18 rules. About 0 are common, 7 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Use standard Microsoft naming conventions
- Very specific: line 10
Use PascalCase for types and methods, camelCase for parameters and private fields
- Very specific: line 11
Use I prefix for interfaces (e.g., IRepository)
- Very specific: line 12
Use Async suffix for async methods (e.g., GetByIdAsync)
- Very specific: line 14
Always use {} for blocks except single-line exits (e.g.
- Very specific: line 15
Always keep single line blocks on one line (e.g., if (x) return y;)
- Distinctive: line 16
Prefer primary constructors for required dependencies
- Distinctive: line 17
Never use primary constructor parameters directly - always assign to private fields for clarity and testability
- Distinctive: line 22
Never allow Core to depend on outer layers
- Very specific: line 35
Use Endpoint<TRequest, TResponse> base class
- Very specific: line 41
Use Value Objects (e.g., ContributorName.From())
- Distinctive: line 48
Use Mediator (source generator) for command/query handling
- Very specific: line 89
All package versions in Directory.Packages.props
- Very specific: line 90
Use <PackageReference Include="..." /> without Version attribute
- Very specific: line 96
Use Microsoft.AspNetCore.Mvc.Testing for API tests
- Distinctive: line 117
Don't include hyphens in project names (template limitation)
- Distinctive: line 120
Use absolute paths in EF migration commands
- Very specific: line 124
Use the predefined tasks: build, publish, watch instead of manual dotnet commands when possible.
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GitHub Copilot Instructions for Clean Architecture Template
Project Overview
This is a Clean Architecture template for .NET 9 that demonstrates Domain-Driven Design (DDD) patterns. It's a starter template, not a reference application - delete sample code once you understand the patterns.
Architecture & Project Structure
C# Conventions
- Use standard Microsoft naming conventions
- Use
PascalCasefor types and methods,camelCasefor parameters and private fields - Use
Iprefix for interfaces (e.g.,IRepository) - Use
Asyncsuffix for async methods (e.g.,GetByIdAsync) - Prefix private fields with
_(e.g.,_repository) - Always use {} for blocks except single-line exits (e.g.
return,throw) - Always keep single line blocks on one line (e.g.,
if (x) return y;) - Prefer primary constructors for required dependencies
- Never use primary constructor parameters directly - always assign to private fields for clarity and testability
Core Dependencies Flow
- Core ← UseCases ← Infrastructure
- Core ← UseCases ← Web
- Never allow Core to depend on outer layers
Key Projects
- Core: Domain entities, aggregates, value objects, specifications, interfaces
- UseCases: Commands/queries (CQRS), Mediator handlers, application logic
- Infrastructure: EF Core, external services, email, file access
- Web: FastEndpoints API, REPR pattern, validation
Development Patterns
API Endpoints (FastEndpoints + REPR)
- One endpoint per file:
Create.cs,Update.cs,Delete.cs,GetById.cs - Separate request/response/validator files:
Create.CreateRequest.cs,Create.CreateValidator.cs - Use
Endpoint<TRequest, TResponse>base class - Example:
src/Clean.Architecture.Web/Contributors/Create.cs
Domain Model (Core)
- Entities use encapsulation - minimize public setters
- Group related entities into Aggregates
- Use Value Objects (e.g.,
ContributorName.From()) - Domain Events for cross-aggregate communication
- Repository interfaces defined in Core, implemented in Infrastructure
Use Cases (CQRS)
- Commands for mutations, Queries for reads
- Queries can bypass repository pattern for performance
- Use Mediator (source generator) for command/query handling
- Chain of responsibility for cross-cutting concerns (logging, validation)
Validation Strategy
- API Level: FluentValidation on request DTOs (FastEndpoints integration)
- Use Case Level: Validate commands/queries (defensive coding)
- Domain Level: Business invariants throw exceptions, assume pre-validated input
Essential Commands
Build & Test
dotnet build Clean.Architecture.slnx
dotnet test Clean.Architecture.slnxEntity Framework Migrations
# From Web project directory
dotnet ef migrations add MigrationName -c AppDbContext -p ../Clean.Architecture.Infrastructure/Clean.Architecture.Infrastructure.csproj -s Clean.Architecture.Web.csproj -o Data/Migrations
dotnet ef database update -c AppDbContext -p ../Clean.Architecture.Infrastructure/Clean.Architecture.Infrastructure.csproj -s Clean.Architecture.Web.csprojTemplate Installation & Usage
dotnet new install Ardalis.CleanArchitecture.Template
dotnet new clean-arch -o Your.ProjectNameKey Dependencies & Patterns
Primary Libraries
- FastEndpoints: API endpoints (replaced Controllers/Minimal APIs)
- Mediator: Command/query handling in UseCases
- EF Core: Data access (SQLite default, easily changed to SQL Server)
- Ardalis.Specification: Repository query specifications
- Ardalis.Result: Error handling pattern
- Serilog: Structured logging
Central Package Management
- All package versions in
Directory.Packages.props - Use
<PackageReference Include="..." />without Version attribute
Test Organization
- UnitTests: Core business logic, use cases
- IntegrationTests: Database, infrastructure components
- FunctionalTests: API endpoints (subcutaneous testing)
- Use
Microsoft.AspNetCore.Mvc.Testingfor API tests
File Organization Conventions
Web Project Structure
Contributors/
Create.cs # Endpoint
Create.CreateRequest.cs # Request DTO
Create.CreateResponse.cs # Response DTO
Create.CreateValidator.cs # FluentValidation
Update.cs, Delete.cs, etc.Sample vs Template
/samplefolder: Complete working example (NimblePros.SampleToDo)/srcfolder: Clean template ready for your project- Study sample for patterns, use src for new projects
Common Gotchas
- Don't include hyphens in project names (template limitation)
- Replace
Ardalis.SharedKernelwith your own shared kernel - Database path in
appsettings.jsonfor SQLite - Use absolute paths in EF migration commands
- FastEndpoints uses different validation approach than Controller-based APIs
VS Code Tasks
Use the predefined tasks: build, publish, watch instead of manual dotnet commands when possible.
Trending
Less talk lately.about the whole repository
Who's talking about ardalis/CleanArchitecture
- Nick Chapsas“How to structure a .NET Solution (project separation & architecture)”YouTube · Feb 1, 2021 · 302k views
- dotnet“Clean Architecture with ASP.NET Core 8 | .NET Conf 2023”YouTube · Nov 18, 2023 · 300k views
- dotnet“Clean Architecture with ASP.NET Core 10”YouTube · Nov 14, 2025 · 110k views
- Ardalis“Nick Chapsas Is Right About Clean Architecture (Mostly)”YouTube · May 18, 2026 · 28k views
- Ardalis“REPR and Clean Architecture”YouTube · Mar 20, 2024 · 23k views
The biggest 5 of 84 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 84
Talked about on GitHub, YouTube, Stack Overflow, Bluesky and the web (84 times).
On GitHub · 44
- Sep 11, 2018Questions on general architecture (Generic repository, multiple dbContexts, service layer) — dotnet-architecture/eShopOnWeb2 reactions · 4 comments
- Feb 25, 2022Show Sample with Multiple Test Projects — irongut/CodeCoverageSummary1 reaction · 4 comments
- Oct 27, 2026[Mirror] ardalis/CleanArchitecture PR 1073: Make SQLite fallback reliable when Docker is unavailable — grandua/dw-public-reviews0 reactions · 1 comment
- Oct 27, 2026CleanArchitecture - Make SQLite fallback reliable when Docker is unavailable — grandua/dw-public-reviews0 reactions · 2 comments
- Aug 20, 2026Migrate to Clean Architecture layering (Domain/Application/Infrastructure/API) — Lazare-Panam/mars-api0 reactions
39 more on GitHub
- Aug 20, 2026Mongo repositories are near-identical copy-paste with no shared base — Lazare-Panam/mars-api0 reactions
- Aug 20, 2026Add automated test suite (unit + integration with Testcontainers) — Lazare-Panam/hiflux-api0 reactions
- Aug 20, 2026Migrate to Clean Architecture layering (Domain/Application/Infrastructure/API) — Lazare-Panam/hiflux-api0 reactions
- Aug 23, 2025Apply Clean architecture pattern — horbunovaolena/ToDo0 reactions
- Jul 27, 2025feat / scheduled post list services — SpaceCoastDevs/PostVector0 reactions · 1 comment
- Jul 25, 2025feat/ crud service for media file — SpaceCoastDevs/PostVector0 reactions
- Jul 8, 2025[🛠️][APLICAÇÃO] Criar proposta de designt da solução — wttorres/fiap-tech-challenge0 reactions · 1 comment
- Feb 23, 2025Clean Architecture — Jay-study-nildana/Azure-CSharp-Corp-Trainer-Syllabus0 reactions · 1 comment
- Jan 10, 2025[dotnet-sdk-10.0.100-alpha.1.25057.15] CleanArchitecture1 get error: System.TypeLoadException: Method 'get_Description' in type 'FastEndpoints.ProducesResponseTypeMetadata' from assembly FastEndpoints does not have an implementation. — dotnet/aspnetcore0 reactions · 15 comments
- Nov 11, 2024Add API-Endpoints — mlennips/smabu0 reactions
- Oct 3, 2024Use TestContainers and Add More Integration/Functional Tests — ardalis/pluralsight-ddd-fundamentals0 reactions
- Aug 15, 2024[dotnet-sdk-9.0.100-rc.1.24409.1] No "400 - bad" ErrorResponse shows in CleanArchitecture app — dotnet/aspnetcore0 reactions · 10 comments
- Aug 8, 2024feat: Activate .editorconfig rules in the project — endatix/endatix0 reactions · 7 comments
- Jun 4, 2024[SUGGESTION] Add "Used By" section to the readme — litedb-org/LiteDB0 reactions · 1 comment
- Mar 25, 2024Tribbles — wallymathieu/redesigned-octo-tribble0 reactions
- Mar 12, 2024Update to Support Dispatching Events with Non-Integer IDs — ardalis/Ardalis.SharedKernel0 reactions · 3 comments
- Nov 21, 2023ardalis/cleanarchitecture 5134626a733de5286a32e36a67fdc1af4671d194 — clearlydefined/curated-data0 reactions · 1 comment
- Nov 16, 2023feat: Clean Architecture Solution from Template — Scorfox/EntertainmentBooking0 reactions
- Mar 31, 2023First prototype — jerohero/triple-research0 reactions
- Mar 30, 2023Define Structure of Software Architecture — zbw-lori/lori-backend0 reactions
- Oct 21, 2022Add Table of Contents to README — ardalis/Ardalis.Extensions0 reactions · 2 comments
- Sep 16, 2022Create a 'dotnet new' template — ardalis/CleanArchitecture.WorkerService0 reactions · 2 comments
- Apr 11, 2022Create structure for Unit Tests — JohanSaisa/GT0 reactions · 1 comment
- Nov 12, 2021move to src/ and tests/ — deislabs/hippo0 reactions
- Nov 12, 2021DeferredHostBuilder starts the host during the build action — dotnet/aspnetcore0 reactions · 14 comments
- Nov 8, 2021clean up architecture — deislabs/hippo0 reactions · 2 comments
- Aug 16, 2021Structuring the application — Neosoft-Private-Limited/rest-dot-net-core0 reactions
- Jun 6, 2021Unit test and integration tests — thangchung/clean-architecture-dotnet0 reactions
- Apr 19, 2021ardalis/CleanArchitecture — pipeline-foundation/projects0 reactions
- Mar 25, 2021Consumers of the package sometimes get 'The call is ambiguous between the following methods or properties' error — ardalis/Specification0 reactions · 5 comments
- Sep 5, 2020refactor(kiteregisterbackend): refactor to clean architecture — PedroJesusRomeroOrtega/KiteRegister0 reactions
- Aug 24, 2020add scaffolding using Clean Architecture Template and renamed the dep… — AnkurMadaan/ankurmadaan.com0 reactions
- Jul 23, 2020Added CleanArchitecture — thangchung/awesome-dotnet-core0 reactions
- Jul 23, 2020Clean Architecture — anitsh/til0 reactions
- Jun 11, 2020migrate to ardalis/clean-code setup — roblankey/dotnetcore0 reactions
- Jan 7, 2020Add https://github.com/ardalis/CleanArchitecture — clean-code-projects/awesome-clean-code0 reactions
- Jul 25, 2019[Brainstorm] Software architecture — thangchung/blog-core0 reactions
- Jul 4, 2019Add enpoint for AspnetCore and Assembly version — cloudnative-netcore/netcorekit0 reactions
- May 25, 2019Blazor for the project — thangchung/blog-core0 reactions · 8 comments
On YouTube · 18
- Feb 1, 2021How to structure a .NET Solution (project separation & architecture) — Nick Chapsas302k views · 345 comments
- Nov 18, 2023Clean Architecture with ASP.NET Core 8 | .NET Conf 2023 — dotnet300k views · 146 comments
- Nov 14, 2025Clean Architecture with ASP.NET Core 10 — dotnet110k views · 84 comments
- May 18, 2026Nick Chapsas Is Right About Clean Architecture (Mostly) — Ardalis28k views · 156 comments
- Mar 20, 2024REPR and Clean Architecture — Ardalis23k views · 62 comments
13 more on YouTube
- Mar 6, 2024What's New in Clean Architecture Template 9.1 — Ardalis20k views · 43 comments
- Jul 22, 2018Architecture Workshop 1 of 7 - Steve Smith shows us Clean Architecture — Fritz's Tech Tips and Chatter18k views · 14 comments
- Aug 22, 2024Чистая архитектура в ASP.NET Core. Структура реального проекта — Дмитрий Юревич16k views · 38 comments
- Mar 26, 2024Clean Architecture with NET 8 — NimblePros7k views · 5 comments
- May 5, 2021Working on Open Source .NET Projects - Clean Architecture — Ardalis3.9k views · 7 comments
- Nov 24, 2024How I structure every ASP.NET Core project (Clean Architecture) — Tech With Pat3.1k views · 5 comments
- Aug 7, 2024ardalis/CleanArchitecture - Gource visualisation — Gourcer2.1k views · 1 comment
- Apr 13, 2022Clean Architecture with ASP.NET Core — Steve Smith — Kevin Griffin [#dotnet | #Azure]1.4k views · 1 comment
- Dec 16, 2023Steve Smith on Clean Architecture [EPISODE 782] — Technology and Friends1.2k views
- Mar 22, 2024Getting Started With Clean Architecture — NimblePros619 views
- Dec 25, 2021TT-Shots : Best Clean Architecture Template For .NET Core Applications — TechieRathore145 views · 1 comment
- Aug 13, 2024GitHub - ardalis/CleanArchitecture: Clean Architecture Solution Template: A starting point for Cl... — GitHub Daily Trend AI Podcast40 views
- Apr 7, 2026Clean Architecture Built in Seconds ardalis/CleanArchitecture — CodeTimelapse32 views
On Stack Overflow · 16
- Aug 14, 2019What is the difference between a 'Use Case Interactor' and a 'Service' in Clean Architecture?21 votes · 1 answer
- Jan 2, 2020What's the recommended folder structure of catalogs in project using IoC11 votes
- Dec 7, 2021Purpose of a dedicated "Solution Items" project in .sln file7 votes · 2 answers
- Nov 23, 2019Avoid cyclic dependency in n-layer architecture in .NET Core7 votes
- Oct 27, 2017How to use StructureMap Registry to Configure EF Core in Separate Project?7 votes · 1 answer
11 more on Stack Overflow
- Oct 16, 2020Unit of work pattern not allowing me to create db context without options4 votes
- Jan 21, 2022How to call SQL functions / stored procedure when using the Repository pattern2 votes
- Jan 16, 2023Why using Directory.Packages.props for non CPM related settings1 vote
- Nov 8, 2022How should I send HTTP Request in Clean Architecture in C#1 vote · 2 answers
- Jul 20, 2022Select only needed field with ListAsync in Ardalis Clean Architecture1 vote · 1 answer
- Nov 22, 2021How to are Domain Events ignored from Migrations in Ardalis CleanArchitecture?1 vote · 1 answer
- Sep 9, 2021In AutoFac, why does the order of RegisterGeneric calls for my generic repositories only work correctly for the last one registered?1 vote · 1 answer
- Jan 23, 2024Seeking guidance on retrieving related data in ASP.NET Core Web API using clean architecture0 votes
- Feb 27, 2017How to use Separate Repository and Service layer assemblies in ASP.NET Core apps0 votes
- Oct 8, 2023What is the proper implementation of a base entity class in clean architecture approach?-1 votes · 1 answer
- Jul 25, 2022How can I make Ef Core totally ignore an object who wraps other properties inside an Entity-1 votes
On Bluesky · 3
- Nov 14, 2024Next there’s a decent-sized sample available in my github.com/ardalis/Clea... repo which also now includes #Aspire support. It shows domain… — @ardalis.com3 likes and reposts · 1 reply
- Dec 11, 2024You can use a library like MediatR and its support for Behaviors (middleware) to do this with very little code and the results are amazing… — @ardalis.com2 likes and reposts · 1 reply
- Aug 6, 2024📦 ardalis / CleanArchitecture ⭐ 15,336 (+21) 🗒 C# Clean Architecture Solution Template: A starting point for Clean Architecture with… — @github-trending.bsky.social1 likes and repost
On the web · 3
- Jun 29, 2025Restructure project to adopt a Clean Architecture-inspired ... — google.com
- Jun 2, 2024Implementing Clean Architecure by Steve "Ardalis" Smith ... — yogihosting.com
- Apr 27, 2018Clean architecture with asp.net core | PDF — google.com
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

