Copilot instructions
.github/copilot-instructions.mdCopilot instructions
Quality
96/100
Scores the file, not the repository.Length
621 words
25 headings · 4 code blocksRepository
18k
— · pushed 17 days agoLast changed
3 days ago
First indexed 3 days ago.1# GitHub Copilot Instructions for Clean Architecture Template23## Project Overview4This 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.56## Architecture & Project Structure78### C# Conventions9- Use standard Microsoft naming conventions10- Use `PascalCase` for types and methods, `camelCase` for parameters and private fields11- Use `I` prefix for interfaces (e.g., `IRepository`)12- Use `Async` suffix for async methods (e.g., `GetByIdAsync`)13- Prefix private fields with `_` (e.g., `_repository`)14- Always use {} for blocks except single-line exits (e.g. `return`, `throw`)15- Always keep single line blocks on one line (e.g., `if (x) return y;`)16- Prefer primary constructors for required dependencies17- Never use primary constructor parameters directly - always assign to private fields for clarity and testability1819### Core Dependencies Flow20- **Core** ← UseCases ← Infrastructure21- **Core** ← UseCases ← Web22- Never allow Core to depend on outer layers2324### Key Projects25- **Core**: Domain entities, aggregates, value objects, specifications, interfaces26- **UseCases**: Commands/queries (CQRS), Mediator handlers, application logic27- **Infrastructure**: EF Core, external services, email, file access28- **Web**: FastEndpoints API, REPR pattern, validation2930## Development Patterns3132### API Endpoints (FastEndpoints + REPR)33- One endpoint per file: `Create.cs`, `Update.cs`, `Delete.cs`, `GetById.cs`34- Separate request/response/validator files: `Create.CreateRequest.cs`, `Create.CreateValidator.cs`35- Use `Endpoint<TRequest, TResponse>` base class36- Example: `src/Clean.Architecture.Web/Contributors/Create.cs`3738### Domain Model (Core)39- Entities use encapsulation - minimize public setters40- Group related entities into Aggregates41- Use Value Objects (e.g., `ContributorName.From()`)42- Domain Events for cross-aggregate communication43- Repository interfaces defined in Core, implemented in Infrastructure4445### Use Cases (CQRS)46- Commands for mutations, Queries for reads47- Queries can bypass repository pattern for performance48- Use Mediator (source generator) for command/query handling49- Chain of responsibility for cross-cutting concerns (logging, validation)5051### Validation Strategy52- **API Level**: FluentValidation on request DTOs (FastEndpoints integration)53- **Use Case Level**: Validate commands/queries (defensive coding)54- **Domain Level**: Business invariants throw exceptions, assume pre-validated input5556## Essential Commands5758### Build & Test59```bash60dotnet build Clean.Architecture.slnx61dotnet test Clean.Architecture.slnx62```6364### Entity Framework Migrations65```bash66# From Web project directory67dotnet ef migrations add MigrationName -c AppDbContext -p ../Clean.Architecture.Infrastructure/Clean.Architecture.Infrastructure.csproj -s Clean.Architecture.Web.csproj -o Data/Migrations6869dotnet ef database update -c AppDbContext -p ../Clean.Architecture.Infrastructure/Clean.Architecture.Infrastructure.csproj -s Clean.Architecture.Web.csproj70```7172### Template Installation & Usage73```bash74dotnet new install Ardalis.CleanArchitecture.Template75dotnet new clean-arch -o Your.ProjectName76```7778## Key Dependencies & Patterns7980### Primary Libraries81- **FastEndpoints**: API endpoints (replaced Controllers/Minimal APIs)82- **Mediator**: Command/query handling in UseCases83- **EF Core**: Data access (SQLite default, easily changed to SQL Server)84- **Ardalis.Specification**: Repository query specifications85- **Ardalis.Result**: Error handling pattern86- **Serilog**: Structured logging8788### Central Package Management89- All package versions in `Directory.Packages.props`90- Use `<PackageReference Include="..." />` without Version attribute9192### Test Organization93- **UnitTests**: Core business logic, use cases94- **IntegrationTests**: Database, infrastructure components95- **FunctionalTests**: API endpoints (subcutaneous testing)96- Use `Microsoft.AspNetCore.Mvc.Testing` for API tests9798## File Organization Conventions99100### Web Project Structure101```102Contributors/103 Create.cs # Endpoint104 Create.CreateRequest.cs # Request DTO105 Create.CreateResponse.cs # Response DTO106 Create.CreateValidator.cs # FluentValidation107 Update.cs, Delete.cs, etc.108```109110### Sample vs Template111- `/sample` folder: Complete working example (NimblePros.SampleToDo)112- `/src` folder: Clean template ready for your project113- Study sample for patterns, use src for new projects114115## Common Gotchas116117- Don't include hyphens in project names (template limitation)118- Replace `Ardalis.SharedKernel` with your own shared kernel119- Database path in `appsettings.json` for SQLite120- Use absolute paths in EF migration commands121- FastEndpoints uses different validation approach than Controller-based APIs122123## VS Code Tasks124Use the predefined tasks: `build`, `publish`, `watch` instead of manual `dotnet` commands when possible.125
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| pytorch/pytorch.github/copilot-instructions.md · 102k | Copilot instructions | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 63 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 3 days ago | |
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| dotnet/roslyn.github/instructions/Compiler.instructions.md · 21k | Copilot instructions | buildteststylearch+3 | 99/100 | 3 days ago | |
| hiyouga/LlamaFactory.github/copilot-instructions.md · 74k | Copilot instructions | setupbuildtestlint-format+5 | 97/100 | 2 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 31k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| rtk-ai/rtk.github/copilot-instructions.md · 74k | Copilot instructions | buildtestlint-formatstyle+2 | 97/100 | 3 days ago | |
| dotnet/roslyn.github/copilot-instructions.md · 21k | Copilot instructions | buildteststylearch+3 | 97/100 | 3 days ago |
