dotnet-csharp-configuration

Implements .NET configuration using the Options pattern, user secrets, and feature flags.

Updated May 22, 2026
One-click install
npx skills add https://github.com/viniciuscs84/sdd-toolkit --skill dotnet-csharp-configuration-viniciuscs84
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-csharp-configuration
Source: https://github.com/viniciuscs84/sdd-toolkit/tree/main/skills/dotnet-csharp-configuration
Command: npx skills add https://github.com/viniciuscs84/sdd-toolkit --skill dotnet-csharp-configuration-viniciuscs84

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Managing application settings in .NET becomes error-prone when configuration is scattered across files, environment variables, and hardcoded values. This Skill provides structured patterns for strongly typed configuration binding, validation, secrets management, and feature flag rollout. ## Core Features & Use Cases - Options Pattern: Bind configuration sections to strongly typed classes and inject them via IOptions<T>, IOptionsMonitor<T>, or IOptionsSnapshot<T> depending on lifetime and reload needs. - Validation and Fail-Fast Startup: Use data annotations, IValidateOptions<T>, and ValidateOnStart() to surface configuration errors at startup instead of at first use. - User Secrets and Environments: Store development secrets outside source control and manage per-environment overrides with appsettings.{Environment}.json. - Feature Flags: Gate endpoints and features with Microsoft.FeatureManagement, including percentage rollouts, targeting filters, and custom IFeatureFilter implementations. - Use Case: You need to configure an SMTP email service with validated settings, keep credentials out of source control during development, and gradually roll out a new dashboard to 50% of users. ## Quick Start Configure my .NET app's SMTP settings using the Options pattern with startup validation and user secrets for development.

Frequently Asked Questions about dotnet-csharp-configuration

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

FAQPage Schema
How do I use the Options pattern in .NET?

Define a strongly typed class with get/set properties, then register it with AddOptions<T>().BindConfiguration(section).ValidateDataAnnotations().ValidateOnStart(). Inject IOptions<T>, IOptionsMonitor<T>, or IOptionsSnapshot<T> depending on your lifetime and reload needs.

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

IOptions<T> is a singleton that never reloads after startup, suitable for static config. IOptionsSnapshot<T> is scoped and reloads per request. IOptionsMonitor<T> is a singleton with live reload and change notifications via OnChange.

How do I store secrets in .NET development without appsettings.json?

Use dotnet user-secrets init, then dotnet user-secrets set to store values in ~/.microsoft/usersecrets outside source control. Secrets load automatically in Development and override appsettings.json. Never use user secrets in production.

How do I add feature flags to an ASP.NET Core app?

Add the Microsoft.FeatureManagement.AspNetCore package, call builder.Services.AddFeatureManagement(), and define flags under the FeatureManagement configuration section. Check flags with IFeatureManager.IsEnabledAsync or gate endpoints with the FeatureGate attribute.

Why does my .NET configuration validation only fail at runtime?

Without ValidateOnStart(), invalid configuration only throws when IOptions<T>.Value is first accessed. Add .ValidateOnStart() to the options registration so validation errors surface at application startup instead of during request handling.

How do I bind multiple instances of the same options type in .NET?

Use named options by passing a name to AddOptions<T>("Name").BindConfiguration(section) for each instance. Resolve them with IOptionsSnapshot<T>.Get(name) or IOptionsMonitor<T>.Get(name), which is useful for multiple API clients.