dotnet-design-pattern-review
它能做什么
这个工具会检查你的 C#/.NET 代码,看看你是否正确使用了常见的设计模式,例如命令模式(Command Pattern)或工厂模式(Factory Pattern)。它还会给出改进代码结构的建议,让代码更有条理,也更容易维护。
适用场景
- ✓当你想知道自己在代码中是否用好了设计模式时。
- ✓当你需要更好地组织一个 C#/.NET 项目时。
- ✓当你想确保代码遵循编程最佳实践时。
技能链接
https://github.com/github/awesome-copilot/blob/main/skills/dotnet-design-pattern-review/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我的 C# 代码中的命令模式和工厂模式。”
每周 5 个新技能,1 分钟读完。
工作原理
你把想要分析的代码片段粘贴进来。工具会读取代码,将其与设计模式规则和最佳实践进行比对,然后告诉你哪些地方做得好,哪些地方还可以改进。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
.NET/C# Design Pattern Review
Review the C#/.NET code in ${selection} for design pattern implementation and suggest improvements for the solution/project. Do not make any changes to the code, just provide a review.
Required Design Patterns
- Command Pattern: Generic base classes (
CommandHandler<TOptions>),ICommandHandler<TOptions>interface,CommandHandlerOptionsinheritance, staticSetupCommand(IHost host)methods - Factory Pattern: Complex object creation service provider integration
- Dependency Injection: Primary constructor syntax,
ArgumentNullExceptionnull checks, interface abstractions, proper service lifetimes - Repository Pattern: Async data access interfaces provider abstractions for connections
- Provider Pattern: External service abstractions (database, AI), clear contracts, configuration handling
- Resource Pattern: ResourceManager for localized messages, separate .resx files (LogMessages, ErrorMessages)
Review Checklist
- Design Patterns: Identify patterns used. Are Command Handler, Factory, Provider, and Repository patterns correctly implemented? Missing beneficial patterns?
- Architecture: Follow namespace conventions (
{Core|Console|App|Service}.{Feature})? Proper separation between Core/Console projects? Modular and readable? - .NET Best Practices: Primary constructors, async/await with Task returns, ResourceManager usage, structured logging, strongly-typed configuration?
- GoF Patterns: Command, Factory, Template Method, Strategy patterns correctly implemented?
- SOLID Principles: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion violations?
- Performance: Proper async/await, resource disposal, ConfigureAwait(false), parallel processing opportunities?
- Maintainability: Clear separation of concerns, consistent error handling, proper configuration usage?
- Testability: Dependencies abstracted via interfaces, mockable components, async testability, AAA pattern compatibility?
- Security: Input validation, secure credential handling, parameterized queries, safe exception handling?
- Documentation: XML docs for public APIs, parameter/return descriptions, resource file organization?
- Code Clarity: Meaningful names reflecting domain concepts, clear intent through patterns, self-explanatory structure?
- Clean Code: Consistent style, appropriate method/class size, minimal complexity, eliminated duplication?
Improvement Focus Areas
- Command Handlers: Validation in base class, consistent error handling, proper resource management
- Factories: Dependency configuration, service provider integration, disposal patterns
- Providers: Connection management, async patterns, exception handling and logging
- Configuration: Data annotations, validation attributes, secure sensitive value handling
- AI/ML Integration: Semantic Kernel patterns, structured output handling, model configuration
Provide specific, actionable recommendations for improvements aligned with the project's architecture and .NET best practices.
常见问题
它会检查哪些设计模式?
它会检查命令模式、工厂模式、依赖注入、仓储模式(Repository)、提供程序模式(Provider)和资源模式(Resource)等,同时也会检查 SOLID 等原则以及通用的 .NET 最佳实践。
它会修改我的代码吗?
不会。它只负责分析并提出改进建议,是否采纳以及如何采纳由你决定。
我需要很懂编程才能用吗?
不需要。这个工具的设计思路是保持简单,即使你是新手,也能借助它了解自己的代码结构是否合理。
详情
作者的原始描述
Review the C#/.NET code for design pattern implementation and suggest improvements.
repo: github/awesome-copilot
热度
- GitHub 星标
- 40k
- 排名
- #7178
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
acquire-codebase-knowledge
40k帮你的智能体理解并编写现有代码项目的文档。它有助于新成员快速上手,或者快速了解项目架构。
acreadiness-assess
40k让你的智能体评估一个项目对 AI 的准备程度,并生成报告。它有助于了解项目在使用 AI 工具方面的准备情况。
acreadiness-generate-instructions
40k帮你的智能体根据评估结果编写 AI 工具的指令文件。它有助于改善 AI 与代码的交互方式,并弥补已发现的不足。
acreadiness-policy
40k让你的智能体协助制定或应用 AI 项目评估的政策。它有助于规范项目的评估方式,并确保合规。