A knowledge-base skill for C# 12 / .NET 8-based coding guidelines.
Overview
This skill provides guidelines to reference when writing code . Unlike code review (csharp-code-review), it guides correct patterns before/during writing.
| Category | csharp-code-review | csharp-best-practices |
|---|---|---|
| Purpose | Reviewing/inspecting existing code | Referencing guidelines when writing code |
| Timing | After writing code | Before/during writing code |
| Output | Review report | Guideline injection |
Arguments
$ARGUMENTS[0]: Topic to look up (optional)- Displays the full rule list when unspecified
- 예:
primary-constructor,record,pattern-matching
Rules
C# 12 Features (.NET 8) — CRITICAL
C# 12 features that must be considered when writing code:
| Rule | File | Description |
|---|---|---|
| Primary Constructors | rules/cs12-primary-constructor.md |
class/struct primary constructor parameters |
| Collection Expressions | rules/cs12-collection-expression.md |
[1, 2, 3] unified syntax |
| Alias Any Type | rules/cs12-alias-any-type.md |
using alias any type |
| Lambda Default Params | rules/cs12-lambda-defaults.md |
Lambda default parameters |
| Inline Arrays | rules/cs12-inline-array.md |
struct fixed-size arrays |
| ref readonly Parameters | rules/cs12-ref-readonly-param.md |
ref/in explicit API |
Modern C# (C# 9-11, .NET 8 compatible) — MEDIUM
| Rule | File | Version |
|---|---|---|
| Record Types | rules/modern-record-type.md |
C# 9 |
| required / init | rules/modern-required-init.md |
C# 11 |
| Pattern Matching | rules/modern-pattern-matching.md |
C# 8-11 |
| List Patterns | rules/modern-list-pattern.md |
C# 11 |
| Raw String Literals | rules/modern-raw-string-literal.md |
C# 11 |
| File-scoped Namespaces | rules/modern-file-scoped-namespace.md |
C# 10 |
Execution
When a topic is specified
Read the corresponding rule file and output the guidelines.
/csharp-best-practices primary-constructor
→ rules/cs12-primary-constructor.md 내용 출력
When no topic is specified
Summarize and output the full rule list.
/csharp-best-practices
→ 12개 규칙 목록 + 간단 설명 출력
Currently received arguments
ARGUMENTS: $ARGUMENTS
Execution instructions
- If ARGUMENTS is present, find the rule file matching the corresponding topic and output its contents.
- If ARGUMENTS is empty, summarize and output the full rule list.
- When outputting rules, Before/After code examplesmust be included.