{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"csharp","version":"0.1.0"},"spec":{"agents_md":"---\ndescription: 'Guidelines for building C# applications'\napplyTo: '**/*.cs'\n---\n\n# C# Development\n\n## C# Instructions\n- Always use the latest version C#, currently C# 14 features.\n- Write clear and concise comments for each function.\n\n## General Instructions\n- Make only high confidence suggestions when reviewing code changes.\n- Write code with good maintainability practices, including comments on why certain design decisions were made.\n- Handle edge cases and write clear exception handling.\n- For libraries or external dependencies, mention their usage and purpose in comments.\n\n## Naming Conventions\n\n- Follow PascalCase for component names, method names, and public members.\n- Use camelCase for private fields and local variables.\n- Prefix interface names with \"I\" (e.g., IUserService).\n\n## Formatting\n\n- Apply code-formatting style defined in `.editorconfig`.\n- Prefer file-scoped namespace declarations and single-line using directives.\n- Insert a newline before the opening curly brace of any code block (e.g., after `if`, `for`, `while`, `foreach`, `using`, `try`, etc.).\n- Ensure that the final return statement of a method is on its own line.\n- Use pattern matching and switch expressions wherever possible.\n- Use `nameof` instead of string literals when referring to member names.\n- Ensure that XML doc comments are created for any public APIs. When applicable, include `\u003cexample\u003e` and `\u003ccode\u003e` documentation in the comments.\n\n## Project Setup and Structure\n\n- Guide users through creating a new .NET project with the appropriate templates.\n- Explain the purpose of each generated file and folder to build understanding of the project structure.\n- Demonstrate how to organize code using feature folders or domain-driven design principles.\n- Show proper separation of concerns with models, services, and data access layers.\n- Explain the Program.cs and configuration system in ASP.NET Core 10 including environment-specific settings.\n\n## Nullable Reference Types\n\n- Declare variables non-nullable, and check for `null` at entry points.\n- Always use `is null` or `is not null` instead of `== null` or `!= null`.\n- Trust the C# null annotations and don't add null checks when the type system says a value cannot be null.\n\n## Data Access Patterns\n\n- Guide the implementation of a data access layer using Entity Framework Core.\n- Explain different options (SQL Server, SQLite, In-Memory) for development and production.\n- Demonstrate repository pattern implementation and when it's beneficial.\n- Show how to implement database migrations and data seeding.\n- Explain efficient query patterns to avoid common performance issues.\n\n## Authentication and Authorization\n\n- Guide users through implementing authentication using JWT Bearer tokens.\n- Explain OAuth 2.0 and OpenID Connect concepts as they relate to ASP.NET Core.\n- Show how to implement role-based and policy-based authorization.\n- Demonstrate integration with Microsoft Entra ID (formerly Azure AD).\n- Explain how to secure both controller-based and Minimal APIs consistently.\n\n## Validation and Error Handling\n\n- Guide the implementation of model validation using data annotations and FluentValidation.\n- Explain the validation pipeline and how to customize validation responses.\n- Demonstrate a global exception handling strategy using middleware.\n- Show how to create consistent error responses across the API.\n- Explain problem details (RFC 9457) implementation for standardized error responses.\n\n## API Versioning and Documentation\n\n- Guide users through implementing and explaining API versioning strategies.\n- Demonstrate Swagger/OpenAPI implementation with proper documentation.\n- Show how to document endpoints, parameters, responses, and authentication.\n- Explain versioning in both controller-based and Minimal APIs.\n- Guide users on creating meaningful API documentation that helps consumers.\n\n## Logging and Monitoring\n\n- Guide the implementation of structured logging using Serilog or other providers.\n- Explain the logging levels and when to use each.\n- Demonstrate integration with Application Insights for telemetry collection.\n- Show how to implement custom telemetry and correlation IDs for request tracking.\n- Explain how to monitor API performance, errors, and usage patterns.\n\n## Testing\n\n- Always include test cases for critical paths of the application.\n- Guide users through creating unit tests.\n- Do not emit \"Act\", \"Arrange\" or \"Assert\" comments.\n- Copy existing style in nearby files for test method names and capitalization.\n- Explain integration testing approaches for API endpoints.\n- Demonstrate how to mock dependencies for effective testing.\n- Show how to test authentication and authorization logic.\n- Explain test-driven development principles as applied to API development.\n\n## Performance Optimization\n\n- Guide users on implementing caching strategies (in-memory, distributed, response caching).\n- Explain asynchronous programming patterns and why they matter for API performance.\n- Demonstrate pagination, filtering, and sorting for large data sets.\n- Show how to implement compression and other performance optimizations.\n- Explain how to measure and benchmark API performance.\n\n## Deployment and DevOps\n\n- Guide users through containerizing their API using .NET's built-in container support (`dotnet publish --os linux --arch x64 -p:PublishProfile=DefaultContainer`).\n- Explain the differences between manual Dockerfile creation and .NET's container publishing features.\n- Explain CI/CD pipelines for NET applications.\n- Demonstrate deployment to Azure App Service, Azure Container Apps, or other hosting options.\n- Show how to implement health checks and readiness probes.\n- Explain environment-specific configurations for different deployment stages.\n","description":"Guidelines for building C# applications","import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/blob/541b7819d8c3545c6df122491af4fa1eae415779/instructions/csharp.instructions.md"},"manifest":{}},"content_hash":[189,62,154,135,71,229,94,68,108,149,134,22,111,235,157,147,46,166,113,131,238,92,113,87,240,80,154,232,35,184,94,138],"trust_level":"unsigned","yanked":false}
