personal-csharp-design-patterns
Installation
SKILL.md
C# Design Patterns
Guidance for selecting and implementing design patterns in modern C#/.NET. Content is structured after refactoring.guru (intent, applicability, pros and cons) and dofactory (.NET-optimized variants that use framework features instead of hand-rolled GoF structure).
Core principles
- Pattern selection comes from the problem, not the other way around. Never recommend a pattern because it is 'good practice'. Identify the design pain first, then check the selection table below. If no pain exists, no pattern is needed.
- Prefer the .NET-native form. Many GoF patterns are already built into the framework or the language. Hand-rolling the classic UML structure when the platform provides it is an anti-pattern. The reference files mark these as '.NET-native form'.
- Modern C# changes the implementation. Use DI containers, delegates, lambdas, generics, records, pattern matching,
IObservable<T>,IEnumerable<T>/yield, and source generators where they replace boilerplate classes. Show the classic structure only when the user asks for it explicitly (e.g. for learning or interviews). - Always state the cost. Every pattern adds indirection. When recommending one, name the tradeoff in one or two sentences (more types, harder navigation, runtime overhead, etc.).
- Style comes from
personal-csharp, not from here. All samples follow its conventions (primary constructors for dependency capture, properties before constructors,sealedby default). When generating real project code, loadpersonal-csharpalongside this skill; on any style conflict,personal-csharpwins.
Workflow
When the user asks for help with patterns: