.claude/skills/gen-in-memory-demo-service/SKILL.md
Use when you need a fake or stub implementation of a service for demos, local development, or testing without a real backend. Generates an in-memory class that implements the real service interface, with seed data, realistic delays, and DI registration that can be swapped. Also invoke when the user mentions: fake service, in-memory stub, demo service, mock service for dev, test double. Domain: Code Generation, Testing. Level: Intermediate.
npx skillsauth add klod68/littlerae gen-in-memory-demo-serviceInstall 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 in-memory demo service implementing I${1:EntityName}Service.
${1:EntityName}${2:MyApp}${3:e.g. int Id, string Name, string Category, bool IsActive}${4:e.g. string name, string category}${5:e.g. int id, string name}${6:e.g. string? nameSearch, string? category}${7:e.g. (1, "Alpha Widget", "Tools"), (2, "Beta Gadget", "Devices")}${2}.Infrastructure.Demo.InMemory${1}Service.cs
/// <summary>
/// In-memory simulation of <see cref="I${1}Service"/> for demos and offline development.
/// Mirrors the real service contract including validation, delays, and error behavior.
/// </summary>
public sealed class InMemory${1}Service : I${1}Service
{
private readonly List<${1}> _items = [];
private readonly List<string> _operationLog = [];
private readonly ILogger<InMemory${1}Service> _logger;
private int _nextId = 1;
public InMemory${1}Service(ILogger<InMemory${1}Service> logger) { ... }
// ── Commands ──────────────────────────────────────────────────────────
// ── Queries ───────────────────────────────────────────────────────────
// ── Observability ─────────────────────────────────────────────────────
// ── Helpers ───────────────────────────────────────────────────────────
}
Key requirements per section:
Commands — match real service validation exactly:
await Task.Delay(100–200, ct).ConfigureAwait(false) to simulate latency"INSERT → usp_Insert${1} @Param=value → NewId=N"bool per the interface contractQueries — simulate reads:
await Task.Delay(50–80, ct).ConfigureAwait(false)if (criteria.X is not null) query = query.Where(...) patternObservability (public — for demo UI use):
IReadOnlyList<string> GetOperationLog() — returns log as read-onlyvoid ClearLog() — clears the logHelpers (private):
void Log(string entry) — prepends [HH:mm:ss.fff] timestampvoid SeedSampleData() — populates _items from context above, then calls _operationLog.Clear()Show both registrations as a code comment:
// Development / demo:
builder.Services.AddScoped<I${1}Service, InMemory${1}Service>();
// Production:
builder.Services.AddScoped<I${1}Service, ${1}Service>();
ConfigureAwait(false) on all awaitsinternal sealed visibility — exposed via DI onlyI${1}Service (except the two observability helpers)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.