Skip to main content

dotnet-best-practices

Apply practical, repository-aligned .NET/C# engineering practices without forcing framework-specific or architecture-specific choices.

跳到安装

来源信息

仓库
markheydon/github-workflows
最近来源活动
2026年4月17日 12:25
检测到的 SKILL.md 语言
英语
星标
1
分支
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
dotnet-best-practices
description
Apply practical, repository-aligned .NET/C# engineering practices without forcing framework-specific or architecture-specific choices.
# .NET/C# Best Practices (Neutral Baseline) Your goal is to help produce maintainable, production-ready .NET code while respecting the repository’s existing conventions and technology choices. ## Core Rule - Follow the repository’s established conventions first. - If conventions are unclear, prefer standard modern .NET practices. - Avoid introducing new frameworks, patterns, or architecture unless requested. ## Scope and Change Discipline - Keep changes focused and minimal for the requested outcome. - Reuse existing abstractions before creating new ones. - Do not change target framework, SDK version, or global project structure unless explicitly asked. - Do not edit generated files. ## API and Design - Use clear names and cohesive methods. - Prefer the least required visibility (`private` > `internal` > `protected` > `public`). - Validate inputs at boundaries. - Throw precise exceptions with actionable messages. - Prefer composition and simple designs over speculative abstractions. ## Async and Reliability - Use async for I/O-bound work end-to-end. - Avoid blocking async calls (`.Result`, `.Wait()`). - Propagate `CancellationToken` where appropriate. - Add timeouts and retries only where they are operationally justified. ## Configuration and Observability - Prefer strongly-typed configuration and validate required settings. - Use structured logging with useful context. - Avoid logging secrets or sensitive data. - Preserve existing telemetry/logging patterns in the repository. ## Security and Data Handling - Validate and sanitize untrusted input. - Use parameterized data access patterns. - Apply least-privilege principles for credentials and access. - Keep secrets out of source code and logs. ## Testing Guidance (Framework-Neutral) - Follow the testing framework already used by the solution. - Add or update tests for changed behaviour, especially public-facing behaviour. - Prefer deterministic tests that run independently. - Use clear Arrange-Act-Assert structure. - Mock only external dependencies when necessary. ## Documentation - Document non-obvious behaviour and important design decisions. - For public APIs, add or maintain XML docs where the repository expects them. - Keep comments focused on intent and rationale, not restating code. ## Performance - Prefer simple, readable implementations first. - Optimize only when justified by measured evidence. - Avoid unnecessary allocations in hot paths when practical. - Stream large payloads when possible instead of buffering entire content. ## Decision Priority When guidance conflicts, use this order: 1. User request 2. Repository conventions 3. This skill 4. General .NET defaults
在 GitHub 查看