Langsung ke konten
Skillpedia
Pemrograman umum40k · #7177

dotnet-best-practices

Fungsinya

Agen AI ini membantu memastikan kode .NET/C# Anda mengikuti praktik terbaik yang direkomendasikan. Agen ini memeriksa dokumentasi, struktur, penggunaan design pattern, dependency injection, pengelolaan resource, penggunaan async/await, testing, konfigurasi, integrasi AI, penanganan error, keamanan, dan kualitas kode secara keseluruhan.

Kapan dipakai

  • ✓Saat menulis kode C# baru.
  • ✓Saat meninjau kode yang sudah ada.
  • ✓Saat ingin mengoptimalkan performa atau keamanan.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/github/awesome-copilot/blob/main/skills/dotnet-best-practices/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit →

Contoh permintaan ke AI

“Periksa apakah kode C# ini sudah mengikuti praktik terbaik.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agen ini menganalisis kode Anda untuk mencari pola tertentu, seperti dokumentasi yang tepat, penggunaan design pattern, dan penanganan error yang benar. Agen membandingkan kode Anda dengan sekumpulan aturan lalu memberikan saran perbaikan.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum

Apa yang dimaksud dengan 'praktik terbaik'?

Itu adalah cara paling efisien dan aman untuk menulis kode, yang membuat kode lebih mudah dirawat dan membantu menghindari kesalahan umum.

Apakah saya perlu memahami semua istilah teknis untuk menggunakan agen ini?

Tidak. Agen ini dirancang untuk membantu meskipun Anda bukan programmer berpengalaman. Agen ini berfokus pada penerapan aturan yang meningkatkan kualitas kode.

Bisakah agen ini memperbaiki kode saya secara otomatis?

Agen ini berfokus pada identifikasi dan saran perbaikan. Perbaikan otomatis mungkin bergantung pada tool lain atau pada tindakan Anda sendiri.

Detail

Deskripsi asli dari pembuat

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

repo: github/awesome-copilot

Popularitas

Bintang GitHub
40k
Peringkat
#7177
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa