.claude/skills/gen-component/SKILL.md
Scaffold a complete new component in one pass: settings class, interface, concrete implementation, DI registration (or static factory for libraries), and a test shell. Use this for new components from scratch; use gen-service-interface, gen-options-class, or gen-di-composition-root for targeted retrofits. Invoke when the user says: create a new service, scaffold a component, generate a class, new provider, new handler, add a component to the project. Domain: Code Generation, Architecture. Level: Intermediate.
npx skillsauth add klod68/littlerae gen-componentInstall 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.
You are a senior software architect and C# developer. Generate a code scaffold that
strictly follows the architectural principles in the workspace root instruction file.
Every output must be ready to compile with no placeholders remaining.
Use // TODO: comments only for logic the caller must implement.
${1|Interface,AbstractBase,ConcreteService,Factory,Package|}${2:e.g. WorkingHoursService}${3:e.g. Executes CRUD operations over WorkingHours records}${4:e.g. MyApp.Application.WorkingHours}${5|Application or Web App,Self-contained class library (no DI container)|}${6|xUnit + FluentAssertions + Moq,MSTest,NUnit + FluentAssertions + Moq|}I${2} before the concrete class.internal sealed unless there is a documented reason otherwise.public.For Application or Web App projects:
public static IServiceCollection Add${2}(
this IServiceCollection services,
Action<${2}Settings> configure)
For self-contained class library projects (no DI container — static library exception):
public static class ${2}Factory
{
public static I${2} Make${2}(...) { ... }
}
Consuming apps register the returned interface in their own DI. No IServiceCollection
reference inside the library.
| Category | Signature | Naming |
|---|---|---|
| Command | Task ExecuteAsync(...) / void Execute(...) | Save, Delete, Send, Register |
| Query | Task<TResult> GetAsync(...) | Get, Find, Load, Fetch |
| Validator | Task<bool> IsAsync(...) / bool Is(...) | Is, Has, Can, Exists |
If a method must deviate from CQS (e.g., insert-and-return-id), add:
// CQS Exception: <reason>
// 1. Preconditions
Guard.AgainstNull(param, nameof(param));
Guard.AgainstNullOrEmpty(stringParam, nameof(stringParam));
// 2. Operation
// TODO: implement core logic
// 3. Postconditions (only when result invariant is non-obvious)
Debug.Assert(result is not null, $"{nameof(${2})} must always return a result.");
Generate ${2}Settings with:
.Domain. → no imports from Application, Infrastructure, or Framework layers.Application. → no imports from Infrastructure or Framework; depend on Domain interfaces only.Infrastructure. → implements Domain/Application interfaces; may reference framework typesI${2})componentType is AbstractBase)internal sealed class ${2})Test framework attribute reference:
| Framework | Class | Method | Exception assert |
|---|---|---|---|
| xUnit | (none) | [Fact] | Assert.Throws<T> / FluentAssertions |
| MSTest | [TestClass] | [TestMethod] | Assert.ThrowsException<T>() |
| NUnit | [TestFixture] | [Test] | Assert.Throws<T> |
nullTODO left in compiled paths — only in method bodies the caller must implementNow generate the full scaffold for: ${2} — ${3}
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.