.claude/skills/gen-embedded-config-loader/SKILL.md
Use when a .NET library needs to ship sensible default configuration that consumers can override without editing source. Generates a 3-tier config system: embedded JSON defaults, appsettings.json overrides, and environment variable overrides via a static accessor. Also invoke when the user mentions: embedded config, library defaults, appsettings override, embedded resource settings. Domain: Code Generation, Configuration. Level: Intermediate.
npx skillsauth add klod68/littlerae gen-embedded-config-loaderInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate an embedded resource configuration loader for the library: ${1:LibraryName}.
${2:MyLib}${3:LibrarySettings}${4:e.g. DefaultLanguage string en-US Language code, CacheTimeoutMinutes int 30 Cache TTL in minutes, EnableRetry bool true Enable transient retry}${2}/Settings/${1:lower}-defaults.json
{
"${3}": {
"Setting1": defaultValue1,
"Setting2": defaultValue2
}
}
All defaults from context above. Values must match the property types exactly (strings quoted, numbers unquoted, bools lowercase).
.csproj entry<ItemGroup>
<EmbeddedResource Include="Settings\${1:lower}-defaults.json">
<LogicalName>${2}.Settings.${1:lower}-defaults.json</LogicalName>
</EmbeddedResource>
</ItemGroup>
Resource name convention: {DefaultNamespace}.{FolderPath.WithDots}.{FileName}
${2}/Settings/${1}Settings.cs
/// <summary>
/// Provides ${1} configuration using 3-tier precedence:
/// consumer appsettings.json → embedded library defaults → hardcoded fallback.
/// </summary>
internal static class ${1}Settings
{
internal const string EmbeddedResourceName =
"${2}.Settings.${1:lower}-defaults.json";
private const string SectionName = "${3}";
private static readonly IConfiguration _embedded = LoadEmbedded();
private static IConfiguration LoadEmbedded()
{
var stream = typeof(${1}Settings).Assembly
.GetManifestResourceStream(EmbeddedResourceName);
var builder = new ConfigurationBuilder();
if (stream is not null)
builder.AddJsonStream(stream);
return builder.Build();
}
// One property per setting — 3-tier ?? chain
// Tier 1: consumer appsettings Tier 2: embedded JSON Tier 3: hardcoded
}
For each setting, generate a property:
/// <summary>[Description]. Default: [default].</summary>
/// <remarks>Override: add <c>"${3}:SettingName": value</c> to appsettings.json.</remarks>
public static string SettingName =>
ConsumerConfig.GetValue<string?>($"{SectionName}:SettingName") // Tier 1
?? _embedded[$"{SectionName}:SettingName"] // Tier 2
?? "hardcoded-fallback"; // Tier 3
For numeric types use int.TryParse(... ?? ...) with the hardcoded fallback as the
out parameter default.
Markdown table for documentation:
| Key | Type | Default | Description | |---|---|---|---|
And an example appsettings.json override block.
// Add to a test or startup diagnostic to confirm the resource is embedded:
var names = typeof(${1}Settings).Assembly.GetManifestResourceNames();
Debug.Assert(names.Contains(${1}Settings.EmbeddedResourceName),
$"Embedded resource '{${1}Settings.EmbeddedResourceName}' not found. " +
$"Check the <EmbeddedResource> entry and <LogicalName> in the .csproj.");
internal static — consumers never access it directlystatic readonly) — never per-callnull stream (misconfigured resource) is handled gracefully — no crashAddJsonFile with file paths — always GetManifestResourceStreamConsumerConfig is assumed to be a static accessor wrapping the host's IConfiguration
(create a stub if it doesn't exist in this codebase)tools
Use when cross-cutting concerns (logging, metrics, validation, authorization) are tangled into command handlers or service methods, when building database command pipelines with reorderable concerns, or when HTTP client pipelines or message handlers need composable, independently-replaceable processing stages. Covers ICommandInterceptor interface, InterceptorPipeline with reverse-chain construction, zero-cost Empty sentinel to skip overhead when no interceptors are registered, and ConfigureAwait(false) discipline for library code. Domain: Architecture, Cross-Cutting Concerns. Level: Intermediate. Tags: interceptor, pipeline, middleware, decorator, cross-cutting-concerns.
development
Use when writing integration tests for Razor Pages, MVC, or Minimal API applications to validate routing, middleware, page rendering, and HTTP behavior without a browser or live server, or when adding fast smoke tests to a CI pipeline. Covers WebApplicationFactory<Program> setup with public partial class Program, in-memory test server, AngleSharp HTML parsing, CSS selector assertions, redirect and status code testing, and a shared static fixture pattern for minimal per-test startup overhead. Domain: Testing, ASP.NET Core. Level: Intermediate. Tags: integration-testing, webapplicationfactory, razor-pages, anglesharp, http-testing.
development
Use when designing indexes for new tables, diagnosing slow queries that are not using indexes efficiently, reviewing index fragmentation and maintenance, or when the current indexing strategy results in key lookups, table scans, or missing index warnings. Covers clustered index key selection (narrow, unique, ever-increasing), non-clustered index design for query patterns, covering indexes with INCLUDE columns, filtered indexes for subset queries, composite index column ordering, DMV-based monitoring for missing and unused indexes, and rebuild vs reorganize maintenance thresholds. Domain: Database, Performance. Level: Intermediate. Tags: index, sql-server, covering-index, filtered-index, performance, dmv, maintenance.
development
Use when building a searchable in-memory catalog or registry for documentation sites, admin panels, or type/API browsers where you need keyword matching, fuzzy search, and ranked results without an external search engine or database. Covers RegistryService with weighted scoring across name, description, keywords, and method names; Levenshtein fuzzy matching; synonym expansion; category and subcategory filtering; and singleton DI registration for datasets of hundreds to low thousands of items. Domain: Search, Data Access Patterns. Level: Intermediate. Tags: search, registry, fuzzy-matching, in-memory, catalog, filtering.