本文へスキップ
Skillpedia
一般的なプログラミング40k · #7177

dotnet-best-practices

できること

このAIエージェントは、.NET/C#のコードが推奨されるベストプラクティスに従っているかを確認するのに役立ちます。ドキュメント、構造、デザインパターンの使い方、依存性の注入、リソース管理、async/awaitの使い方、テスト、設定、AI連携、エラー処理、セキュリティ、全体的なコード品質をチェックします。

使う場面

  • ✓新しくC#のコードを書くとき。
  • ✓既存のコードをレビューするとき。
  • ✓性能やセキュリティを最適化したいとき。

スキルのリンク

https://github.com/github/awesome-copilot/blob/main/skills/dotnet-best-practices/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/github/awesome-copilot/blob/main/skills/dotnet-best-practices/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“このC#コードがベストプラクティスに従っているか確認してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、適切なドキュメントの有無、デザインパターンの使い方、正しいエラー処理などの特定のパターンをコードから分析します。一連のルールと照らし合わせ、改善案を提案します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

.NET/C# Best Practices

Your task is to ensure .NET/C# code in ${selection} meets the best practices specific to this solution/project. This includes:

Documentation & Structure

  • Create comprehensive XML documentation comments for all public classes, interfaces, methods, and properties
  • Include parameter descriptions and return value descriptions in XML comments
  • Follow the established namespace structure: {Core|Console|App|Service}.{Feature}

Design Patterns & Architecture

  • Use primary constructor syntax for dependency injection (e.g., public class MyClass(IDependency dependency))
  • Implement the Command Handler pattern with generic base classes (e.g., CommandHandler<TOptions>)
  • Use interface segregation with clear naming conventions (prefix interfaces with 'I')
  • Follow the Factory pattern for complex object creation.

Dependency Injection & Services

  • Use constructor dependency injection with null checks via ArgumentNullException
  • Register services with appropriate lifetimes (Singleton, Scoped, Transient)
  • Use Microsoft.Extensions.DependencyInjection patterns
  • Implement service interfaces for testability

Resource Management & Localization

  • Use ResourceManager for localized messages and error strings
  • Separate LogMessages and ErrorMessages resource files
  • Access resources via _resourceManager.GetString("MessageKey")

Async/Await Patterns

  • Use async/await for all I/O operations and long-running tasks
  • Return Task or Task<T> from async methods
  • Use ConfigureAwait(false) where appropriate
  • Handle async exceptions properly

Testing Standards

  • Use MSTest framework with FluentAssertions for assertions
  • Follow AAA pattern (Arrange, Act, Assert)
  • Use Moq for mocking dependencies
  • Test both success and failure scenarios
  • Include null parameter validation tests

Configuration & Settings

  • Use strongly-typed configuration classes with data annotations
  • Implement validation attributes (Required, NotEmptyOrWhitespace)
  • Use IConfiguration binding for settings
  • Support appsettings.json configuration files

Semantic Kernel & AI Integration

  • Use Microsoft.SemanticKernel for AI operations
  • Implement proper kernel configuration and service registration
  • Handle AI model settings (ChatCompletion, Embedding, etc.)
  • Use structured output patterns for reliable AI responses

Error Handling & Logging

  • Use structured logging with Microsoft.Extensions.Logging
  • Include scoped logging with meaningful context
  • Throw specific exceptions with descriptive messages
  • Use try-catch blocks for expected failure scenarios

Performance & Security

  • Use C# 12+ features and .NET 8 optimizations where applicable
  • Implement proper input validation and sanitization
  • Use parameterized queries for database operations
  • Follow secure coding practices for AI/ML operations

Code Quality

  • Ensure SOLID principles compliance
  • Avoid code duplication through base classes and utilities
  • Use meaningful names that reflect domain concepts
  • Keep methods focused and cohesive
  • Implement proper disposal patterns for resources
よくある質問

「ベストプラクティス」とは何ですか?

コードを書く際に、最も効率的で安全とされる方法のことです。保守しやすくなり、よくある間違いを避けられます。

このエージェントを使うには、専門用語をすべて理解している必要がありますか?

いいえ。経験の浅いプログラマーでも使えるように設計されています。コードの品質を高めるルールを適用することに重点を置いています。

エージェントがコードを自動で修正してくれますか?

このエージェントは問題の特定と改善案の提示に重点を置いています。自動修正は別のツールを使うか、あなた自身が行う必要がある場合があります。

詳細

作者による元の説明

Ensure .NET/C# code meets best practices for the solution/project.

repo: github/awesome-copilot

人気

GitHubのスター
40k
ランキング
#7177
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル