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 CancellationToken through async methods — no exceptions
  • Enable <Nullable>enable</Nullable> in all .csproj files; use string? for nullable, string.Empty for non-nullable defaults
  • Constructor injection only — never use property or field injection
  • Use IEntityTypeConfiguration<T> for all EF entity configs; never configure in OnModelCreating directly
  • Use AsNoTracking() for all read-only queries; project to DTOs with .Select() early
  • Use record types for DTOs, not classes
  • Apply sealed to classes that should not be inherited
  • Use required keyword (C# 11+) for required properties instead of constructor enforcement
  • Prefer is not null over != null; use nameof() 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.

04 同仓库更多 Skills