What problem does it solve?
Many .NET projects read configuration values directly and lack startup validation, which leads to runtime errors, leaked secrets, and fragile environment overrides. This Skill codifies patterns to replace ad-hoc configuration reads with strongly-typed options, layered appsettings, and early validation so configuration problems fail fast and are easier to maintain.
Core Features & Use Cases
- Strongly-typed Options: Encourage creating Options classes for configuration sections and injecting via IOptions, IOptionsSnapshot, or IOptionsMonitor as appropriate.
- Startup Validation and Validators: Use data annotation validation and IValidateOptions with ValidateOnStart to ensure misconfiguration is detected at application startup.
- Configuration Layering & Secrets: Apply appsettings.json < appsettings.Environment.json < environment variables < user secrets/Key Vault and migrate secrets out of source control.
- Use Case: Convert a legacy service that reads connection strings from IConfiguration into a validated DatabaseOptions class bound in Program.cs, with secrets moved to user secrets in development and Key Vault in production.
Quick Start
Create a strongly-typed options class, bind it in Program.cs with ValidateOnStart, and move any secrets to user secrets or Key Vault.