csharp-aspnetcore

Enforce DI lifetimes, HttpClient factory usage, and RFC 7807 responses in ASP.NET Core.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/CloudyWing/ai-dotfiles --skill csharp-aspnetcore
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: csharp-aspnetcore
Source: https://github.com/CloudyWing/ai-dotfiles/tree/main/skills/csharp-aspnetcore
Command: npx skills add https://github.com/CloudyWing/ai-dotfiles --skill csharp-aspnetcore

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents common ASP.NET Core mistakes such as incorrect dependency injection lifetimes, improper HttpClient usage that leads to socket exhaustion, inconsistent API response formats, and missing API versioning that causes breaking changes and maintenance burden.

Core Features & Use Cases

  • DI Lifetime Guidance: Recommends Singleton/Scoped/Transient usage patterns and warns about captive dependencies and injecting scoped services into singletons.
  • HttpClient Safety: Enforces IHttpClientFactory or typed/named clients instead of creating HttpClient instances per request.
  • Response Consistency & Versioning: Mandates ProblemDetails-based error responses and respects project API versioning settings when generating or modifying endpoints.
  • Configuration & Background Services: Promotes the Options Pattern for typed configuration and correct BackgroundService/IHostedService registration patterns.
  • Use Case: When adding a new controller or refactoring services, the skill audits registrations, suggests lifetime changes, enforces HttpClient factory usage, and ensures error responses follow RFC 7807.

Quick Start

Apply the csharp-aspnetcore skill to audit the current repository for DI lifetimes, HttpClient usage, response formatting, options pattern usage, and API versioning and provide actionable recommendations.

Frequently Asked Questions about csharp-aspnetcore

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent captive dependency issues when configuring ASP.NET Core dependency injection lifetimes?

To prevent captive dependency issues in ASP.NET Core dependency injection, avoid injecting scoped services into singletons. The skill audits DI registrations to recommend correct Singleton, Scoped, or Transient patterns and flags risky lifetime combinations.

Why does creating HttpClient instances per request cause socket exhaustion in ASP.NET Core and how do I fix it?

Creating HttpClient instances per request causes socket exhaustion in ASP.NET Core because sockets are not immediately released. The skill fixes this by enforcing IHttpClientFactory or typed and named clients for resilient HTTP client management.

What is the ProblemDetails format and when do I need it for ASP.NET Core API error responses?

ProblemDetails is a standardized format for API error responses defined in RFC 7807. You need it in ASP.NET Core to ensure consistent error response structures across endpoints, which the skill enforces by mandating this format for all API errors.

How do I configure typed settings using the Options Pattern in an ASP.NET Core background service?

To configure typed settings using the Options Pattern in an ASP.NET Core background service, bind configuration sections to strongly typed classes. The skill promotes this pattern to ensure correct configuration access and proper BackgroundService registration.

Does this skill enforce API versioning settings when modifying ASP.NET Core endpoints?

Yes, the skill enforces API versioning settings when modifying ASP.NET Core endpoints. It respects existing project API versioning configurations to prevent breaking changes and reduce maintenance burden during endpoint generation or refactoring.

What is the best way to audit an ASP.NET Core codebase for incorrect DbContext scoped lifetime usage?

The best way to audit an ASP.NET Core codebase for incorrect DbContext scoped lifetime usage is applying this skill. It audits registrations to ensure scoped DbContext usage and verifies that no scoped services are injected into singleton dependencies.