Skip to content
Back to skills

Microsoft Extensions

ASecurity

Use 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 patterns into non-web .NET apps; cleaning up service registration, typed HTTP. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit ta...

  • 485 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added May 27, 2026
developmentgo

Works with

  • cli

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned May 27, 2026

npx -y skills add managedcode/dotnet-skills --skill microsoft-extensions --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Microsoft Extensions?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Microsoft Extensions
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/managedcode-microsoft-extensions/badge)](https://www.skillsdirectory.com/skills/managedcode-microsoft-extensions)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: microsoft-extensions
description: "Use 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 patterns into non-web .NET apps; cleaning up service registration, typed HTTP. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made."
compatibility: "Relevant to console apps, workers, ASP.NET Core apps, functions, and reusable libraries."
---

# Microsoft.Extensions for .NET

## Trigger On

- wiring dependency injection, configuration, logging, or options
- introducing Generic Host patterns into non-web .NET apps
- cleaning up service registration, typed HTTP clients, or shared infrastructure code

## Workflow

1. Prefer the Generic Host for apps that need configuration, DI, logging, hosted services, or coordinated startup.
2. Keep service registration predictable: composition at the edge, concrete implementations hidden behind interfaces only where that abstraction buys flexibility.
3. Use options binding for structured configuration and validate configuration at startup when bad settings would fail later at runtime.
4. Prefer `IHttpClientFactory` and typed or named clients for outbound HTTP instead of ad-hoc singleton or per-call `HttpClient` usage.
5. Use logging categories and config-driven log levels rather than scattered ad-hoc logging behavior.
6. Avoid building mini-frameworks over Microsoft.Extensions unless the repo genuinely needs reusable composition primitives.

## Deliver

- clean host wiring and service registration
- configuration and logging that are observable and testable
- infrastructure code that fits naturally with the .NET stack

## Validate

- service lifetimes are correct
- configuration is strongly typed where it matters
- host setup remains easy to debug and reason about

## References

- [patterns.md](references/patterns.md) - DI patterns, Configuration patterns, Options pattern, Logging patterns, HttpClientFactory patterns, Hosted Service patterns
- [anti-patterns.md](references/anti-patterns.md) - Common mistakes with DI, configuration, options, logging, HttpClient, and hosted services

Files in this skill

  • SKILL.md2.4 KB
  • manifest.json91 B
  • references/anti-patterns.md16.2 KB
  • references/patterns.md13.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…