AGENT SKILL
dotnet
Clean Architecture principles and C# conventions for .NET projects
- License 许可
- MIT
- 最近更新
- 2026-11-05
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- dotnet
- license
- MIT
- metadata
- { "author": "shahboura", "version": "2.0.0", "audience": "developers", "workflow": "development" }
- description
- Clean Architecture principles and C# conventions for .NET projects
- compatibility
- opencode
02 资源文件 1
03 SKILL.md 正文
What I do
- Enforce Clean Architecture layer boundaries and dependency direction
- Apply C# coding standards with async safety and nullable correctness
- Guide Entity Framework Core configuration and query optimization
When to use me
Use this when working on .NET/C# projects that follow Clean Architecture patterns.
Key Rules
- Dependency direction: Domain → Application → Infrastructure → WebAPI (inner layers must never reference outer)
- ALWAYS pass
CancellationTokenthrough async methods — no exceptions - Enable
<Nullable>enable</Nullable>in all .csproj files; usestring?for nullable,string.Emptyfor non-nullable defaults - Constructor injection only — never use property or field injection
- Use
IEntityTypeConfiguration<T>for all EF entity configs; never configure inOnModelCreatingdirectly - Use
AsNoTracking()for all read-only queries; project to DTOs with.Select()early - Use
recordtypes for DTOs, not classes - Apply
sealedto classes that should not be inherited - Use
requiredkeyword (C# 11+) for required properties instead of constructor enforcement - Prefer
is not nullover!= null; usenameof()in exception parameter names - Interfaces belong in the Application layer; implementations in Infrastructure
- Use a verify-fix-verify loop: run the validation commands below, fix any failures, and rerun until all checks pass
Validation Commands
dotnet restore
dotnet build
dotnet format
dotnet test
See references/clean-architecture-examples.md for worked examples.