$npx -y skills add managedcode/dotnet-skills --skill microsoft-extensionsUse the Microsoft.Extensions stack correctly across Generic Host, dependency injection, configuration, logging, options, HttpClientFactory, and other shared infrastructure patterns. USE FOR: wiring dependency injection, configuration, logging, or options; introducing Generic Host
| 1 | # Microsoft.Extensions for .NET |
| 2 | |
| 3 | ## Trigger On |
| 4 | |
| 5 | - wiring dependency injection, configuration, logging, or options |
| 6 | - introducing Generic Host patterns into non-web .NET apps |
| 7 | - cleaning up service registration, typed HTTP clients, or shared infrastructure code |
| 8 | |
| 9 | ## Workflow |
| 10 | |
| 11 | 1. Prefer the Generic Host for apps that need configuration, DI, logging, hosted services, or coordinated startup. |
| 12 | 2. Keep service registration predictable: composition at the edge, concrete implementations hidden behind interfaces only where that abstraction buys flexibility. |
| 13 | 3. Use options binding for structured configuration and validate configuration at startup when bad settings would fail later at runtime. |
| 14 | 4. Prefer `IHttpClientFactory` and typed or named clients for outbound HTTP instead of ad-hoc singleton or per-call `HttpClient` usage. |
| 15 | 5. Use logging categories and config-driven log levels rather than scattered ad-hoc logging behavior. |
| 16 | 6. For Kubernetes-hosted services, prefer the stable `Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes` package from the 10.7+ line when CPU/memory request and limit metrics should come from pod resource quotas. |
| 17 | 7. Avoid building mini-frameworks over Microsoft.Extensions unless the repo genuinely needs reusable composition primitives. |
| 18 | |
| 19 | ## Current Upstream Notes |
| 20 | |
| 21 | - `dotnet/extensions` `v10.8.1` is an AI-library servicing release for approval-resume ordering and stateless reasoning state; it does not change the Generic Host, dependency injection, configuration, logging, options, or `IHttpClientFactory` patterns in this skill. |
| 22 | - Keep Microsoft.Extensions package versions aligned within the repo's selected servicing line, then rerun host startup and options-validation tests after upgrading. |
| 23 | |
| 24 | ## Deliver |
| 25 | |
| 26 | - clean host wiring and service registration |
| 27 | - configuration and logging that are observable and testable |
| 28 | - infrastructure code that fits naturally with the .NET stack |
| 29 | |
| 30 | ## Validate |
| 31 | |
| 32 | - service lifetimes are correct |
| 33 | - configuration is strongly typed where it matters |
| 34 | - host setup remains easy to debug and reason about |
| 35 | - Kubernetes resource monitoring uses the stable quota-provider APIs when pod request/limit dimensions matter |
| 36 | |
| 37 | ## References |
| 38 | |
| 39 | - [patterns.md](references/patterns.md) - DI patterns, Configuration patterns, Options pattern, Logging patterns, HttpClientFactory patterns, Hosted Service patterns |
| 40 | - [anti-patterns.md](references/anti-patterns.md) - Common mistakes with DI, configuration, options, logging, HttpClient, and hosted services |