microsoft-extensions-configuration

Implements strongly-typed configuration binding and startup validation for .NET applications.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill microsoft-extensions-configuration-agibuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: microsoft-extensions-configuration
Source: https://github.com/AGIBuild/dotnet.CI.template/tree/main/.cursor/skills/microsoft-extensions-configuration
Command: npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill microsoft-extensions-configuration-agibuild

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? .NET applications often fail at runtime due to misconfiguration such as missing connection strings, invalid URLs, or out-of-range values, with errors surfacing deep in business logic far from where configuration is loaded. This Skill provides patterns to bind configuration to strongly-typed classes and validate it at application startup, so invalid settings fail fast with clear error messages. ## Core Features & Use Cases - Options Binding: Bind appsettings.json sections to POCO settings classes and consume them via IOptions<T>, IOptionsSnapshot<T>, or IOptionsMonitor<T>. - Startup Validation: Apply Data Annotations validation and custom IValidateOptions<T> validators with ValidateOnStart() to catch misconfiguration immediately. - Advanced Scenarios: Handle named options for multiple instances, validators with injected dependencies like IHostEnvironment, post-configuration, and live configuration reload in background services. - Use Case: When building an ASP.NET Core service that connects to SMTP, databases, or Akka.NET clusters, use this Skill to define settings classes, register validators, and guarantee the app refuses to start with invalid configuration. ## Quick Start Ask the AI to set up a strongly-typed SmtpSettings configuration class with startup validation using IValidateOptions in your .NET project.

Frequently Asked Questions about microsoft-extensions-configuration

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

FAQPage Schema
How do I validate configuration at startup in .NET?▼

Use AddOptions<T>().BindConfiguration(section).ValidateDataAnnotations().ValidateOnStart() to run validation when the application starts. Without ValidateOnStart(), validation only runs when options are first accessed, which can happen long after startup.

When should I use IValidateOptions instead of Data Annotations?▼

Use IValidateOptions<T> for cross-property validation, conditional rules, environment-specific checks, or when the validator needs injected dependencies like IHostEnvironment or ILogger. Data Annotations cover simple cases like Required, Range, and EmailAddress.

What is the difference between IOptions, IOptionsSnapshot, and IOptionsMonitor?▼

IOptions<T> is a singleton read once at startup. IOptionsSnapshot<T> is scoped and reloads per request, suiting web apps. IOptionsMonitor<T> is a singleton that supports change notifications via OnChange, ideal for background services reacting to configuration updates.

How do I bind multiple instances of the same settings class in .NET?▼

Use named options: call AddOptions<T>("Name").BindConfiguration("Section:Name") for each instance, then resolve them with IOptionsSnapshot<T>.Get("Name"). Validators receive the name parameter to apply instance-specific rules.

Why does my .NET configuration validation not run at startup?▼

Validation does not run at startup if ValidateOnStart() is missing from the options registration chain. Also ensure validators return ValidateOptionsResult.Fail instead of throwing exceptions, which breaks the validation chain.