.claude/skills/gen-resilience-policy/SKILL.md
Use when adding retry or resilience handling to an HTTP client or external dependency call. Generates a Polly v8 policy with exponential backoff, transient error detection, jitter, and an observability callback. Also invoke when the user mentions: add retry, resilience policy, Polly policy, transient fault handling. Domain: Code Generation, Resilience. Level: Intermediate.
npx skillsauth add klod68/littlerae gen-resilience-policyInstall 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 a resilience policy for the following operation.
${1|Database CRUD,Database batch,HTTP API call,Message queue,File I/O,Background job,Health check|}${2:e.g. SQL Server, PostgreSQL, HttpClient, RabbitMQ}${3|Yes,No|}${4:e.g. 30 seconds}${5|User-facing API,Background job,Batch process,Health check|}Place in a ResiliencePolicies static class (create if not present):
/// <summary>
/// [Description of what operation this policy protects.]
/// Total worst-case retry window: [calculated — sum of all max delays].
/// </summary>
public static readonly IResiliencePolicy [PolicyName] = ResiliencePolicyFactory.Create(
maxRetryCount: [N],
initialDelay: TimeSpan.FromMilliseconds([N]),
maxDelay: TimeSpan.FromSeconds([N]),
backoffMultiplier: 2.0,
useJitter: true,
onRetry: (ex, attempt, delay) =>
Log.Warning(
"Retry {Attempt} for {Operation} after {Delay}ms: {Error}",
attempt, "[OperationName]", delay.TotalMilliseconds, ex.Message));
| Attempt | Base delay | With jitter (±25%) | Cumulative max | |---|---|---|---| | 1 | | | | | 2 | | | | | N | | | |
Document why these values were chosen given the operation type, idempotency, caller timeout, and environment. Include the worst-case total window calculation.
${4})OperationCanceledException is never retriedonRetry callback logs attempt number, delay, and exception message| Environment | Max retries | Initial delay | Total window | |---|---|---|---| | User-facing API | 2–3 | 50–100 ms | < 2 s | | Background job | 3–5 | 500 ms–1 s | < 1 min | | Batch process | 5–10 | 1–5 s | < 5 min | | Non-idempotent | 0–1 | any | minimal | | Health check | 0 | — | fail fast |
public static readonly — stateless, created once, thread-safeOperationCanceledException — always propagate cancellationonRetry uses structured logging templates — no string interpolationtools
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.