Saltar al contenido
Skillpedia
Programación general40 mil · #7177

dotnet-best-practices

Qué hace

Este agente de IA te ayuda a asegurar que tu código .NET/C# siga las buenas prácticas recomendadas. Revisa la documentación, la estructura, el uso de patrones de diseño, la inyección de dependencias, la gestión de recursos, el uso de async/await, las pruebas, la configuración, la integración con IA, el manejo de errores, la seguridad y la calidad general del código.

Cuándo usarla

  • ✓Cuando escribes código C# nuevo.
  • ✓Cuando revisas código existente.
  • ✓Cuando quieres optimizar el rendimiento o la seguridad.

Link de la skill

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

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/github/awesome-copilot/blob/main/skills/dotnet-best-practices/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Revisa si este código C# sigue las buenas prácticas.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

El agente analiza tu código buscando patrones concretos, como una documentación adecuada, el uso de patrones de diseño y un manejo de errores correcto. Compara tu código con un conjunto de reglas y te sugiere mejoras.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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
Preguntas frecuentes

¿Qué son las 'buenas prácticas'?

Son las formas más eficientes y seguras de escribir código, que facilitan su mantenimiento y evitan errores comunes.

¿Necesito entender todos los términos técnicos para usar este agente?

No, el agente está pensado para ayudarte aunque no seas un programador experimentado. Se centra en aplicar reglas que mejoran la calidad del código.

¿El agente puede corregir mi código automáticamente?

Este agente se centra en identificar y sugerir mejoras. La corrección automática puede depender de otras herramientas o de que tú la hagas.

Detalles

Descripción original del autor

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

repo: github/awesome-copilot

Popularidad

Estrellas en GitHub
40 mil
Posición en el ranking
#7177
Licencia
MIT
Actualizada
15/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas