aaronontheweb avatar

Microsoft Extensions Configuration

If you're tired of runtime configuration failures in .NET apps, this walks you through the Options pattern with startup validation. It covers IOptions vs IOptionsSnapshot vs IOptionsMonitor, when to use Data Annotations versus IValidateOptions for complex cross-property rules, and how ValidateOnStart makes misconfiguration fail immediately instead of deep in production. The examples are practical, from basic appsettings.json binding to background services that react to config changes. The anti-patterns section alone is worth it, especially the reminder to never inject IConfiguration directly when you could have strongly-typed, validated settings classes instead.

skills.sh installs
609
GitHub stars
1.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add aaronontheweb/dotnet-skills --skill microsoft-extensions-configuration --agent claude-code

Installs into .claude/skills of the current project.

Files

Microsoft.Extensions Configuration Patterns

When to Use This Skill

Use this skill when:

  • Binding configuration from appsettings.json to strongly-typed classes
  • Validating configuration at application startup (fail fast)
  • Implementing complex validation logic for settings
  • Designing configuration classes that are testable and maintainable
  • Understanding IOptions, IOptionsSnapshot, and IOptionsMonitor

Reference Files

  • advanced-patterns.md: Validators with dependencies, named options, complete production example (AkkaSettings), and testing validators

Why Configuration Validation Matters

The Problem: Applications often fail at runtime due to misconfiguration - missing connection strings, invalid URLs, out-of-range values. These failures happen deep in business logic, far from where configuration is loaded.

The Solution: Validate configuration at startup. If invalid, fail immediately with a clear error message.

Sponsors

Details

Repository
github.com/aaronontheweb/dotnet-skills
Category
.NET & C#
First seen
Jun 3, 2026

More from aaronontheweb/dotnet-skills

All 34

Recommended

More .NET & C#
1aaronontheweb avatarcrap-analysisaaronontheweb/dotnet-skillsAnalyze code coverage and CRAP (Change Risk Anti-Patterns) scores to identify high-risk code. Use OpenCover format with ReportGenerator for Risk Hotspots showin581skills.sh installs
2aaronontheweb avatarmjml-email-templatesaaronontheweb/dotnet-skillsBuild responsive email templates using MJML markup language. Compiles to cross-client HTML that works in Outlook, Gmail, and Apple Mail. Includes template rende513skills.sh installs
3aaronontheweb avataraspire-service-defaultsaaronontheweb/dotnet-skillsCreate a shared ServiceDefaults project for Aspire applications. Centralizes OpenTelemetry, health checks, resilience, and service discovery configuration acros497skills.sh installs
4aaronontheweb avataraspire-configurationaaronontheweb/dotnet-skillsConfigure Aspire AppHost to emit explicit app config via environment variables; keep app code free of Aspire clients and service discovery.487skills.sh installs
5umbraco avatarpackage-script-writerumbraco/umbraco-cms-backoffice-skillsGenerate Umbraco CMS installation scripts using the Package Script Writer CLI391skills.sh installs
6mryll avatarvertical-slice-architecturemryll/skillsEnforce Vertical Slice Architecture (VSA) when building applications in any language (Go, .NET/C#, Java, Kotlin, TypeScript, Python, etc.) and any type (web API327skills.sh installs