agentskills.codes

Use Refit to define type-safe REST clients in .NET as C# interfaces backed by HttpClient — covering interface definition (HTTP verb attributes, parameter binding, return types), DI registration with AddRefitClient, DelegatingHandler pipelines for auth/headers/logging, error handling with IApiRespons

Install

mkdir -p .claude/skills/refit && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14276" && unzip -o skill.zip -d .claude/skills/refit && rm skill.zip

Installs to .claude/skills/refit

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Use Refit to define type-safe REST clients in .NET as C# interfaces backed by HttpClient — covering interface definition (HTTP verb attributes, parameter binding, return types), DI registration with AddRefitClient, DelegatingHandler pipelines for auth/headers/logging, error handling with IApiResponse, RefitSettings, and multipart uploads. Trigger whenever the user writes, reviews, or asks about Refit clients, REST API interfaces, AddRefitClient, IApiResponse, ApiException, DelegatingHandler for HTTP, typed HTTP clients, RestService.For, or consuming HTTP APIs in .NET — even if they don't mention "Refit" by name. Always prefer this skill over guessing; Refit's attribute model, IApiResponse vs throws-by-default behavior, handler chain ordering, and scoped-client lifetime rules all have non-obvious failure modes that are easy to get wrong.
848 charsno explicit “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)

About this skill

Refit

Refit turns a C# interface you annotate with HTTP verb attributes into a working client backed by HttpClient. You write the contract; Refit generates the implementation at compile time (source generator) or runtime.

NuGet packages

  • Refit — core (always required)
  • Refit.HttpClientFactoryAddRefitClient<T>() DI integration (add for ASP.NET Core / DI apps)

Quick reference

TopicSee
HTTP verbs, parameter binding, return types, headersinterface-design.md
DI registration, AddRefitClient, RefitSettings, scoped clientsdi-registration.md
Auth handlers, Bearer tokens, per-request and static headersauthentication.md
IApiResponse, ApiException, non-throwing error handlingerror-handling.md

The golden path

// 1. Define the interface
public interface IProductsClient
{
    [Get("/api/products/{id}")]
    Task<ProductDto> GetProductAsync(Guid id, CancellationToken cancellationToken = default);

    [Post("/api/products")]
    Task<IApiResponse<ProductDto>> CreateProductAsync([Body] CreateProductRequest body, CancellationToken cancellationToken = default);
}

// 2. Register with DI
services.AddRefitClient<IProductsClient>()
    .ConfigureHttpClient(c => c.BaseAddress = new Uri("https://api.example.com"))
    .AddHttpMessageHandler<AuthHandler>()
    .AddStandardResilienceHandler();

// 3. Use via injection
public class ProductsPage(IProductsClient client)
{
    async Task LoadAsync()
    {
        var product = await client.GetProductAsync(id);
    }
}

Critical rules

  • Always include CancellationToken cancellationToken = default as the last parameter on every method.
  • Handler chain order matters: the first AddHttpMessageHandler call is outermost (executes first on send, last on receive). Typical order: Resilience → Auth → Correlation → Network.
  • Never register scoped DelegatingHandlers as singletons — they'll capture scoped services and cause stale state. Register handlers as AddTransient.
  • IApiResponse<T> suppresses throwing on non-2xx; raw Task<T> throws ApiException. Choose at the interface level per method.
  • InnerHandler must be null when registering handlers via DI (AddHttpMessageHandler); assign it only when constructing manually with RestService.For<T>.

aspnet-sse

aalmada

Implement Server-Sent Events (SSE) in ASP.NET Core using TypedResults.ServerSentEvents, SseItem<T>, and Channel-based pub/sub — including the notification service pattern, multi-instance Redis scaling, and the SseParser client. Trigger whenever the user writes, reviews, or asks about SSE, real-time

00

etag

aalmada

Use this skill for any request involving HTTP ETags, conditional requests, or optimistic concurrency in REST APIs: implementing/explaining ETag headers, preventing lost updates, designing cache validation or conditional GET/PUT/DELETE, explaining If-Match, If-None-Match, 304 Not Modified, or 412 Pre

00

tunit

aalmada

Use this skill to write, review, and fix TUnit tests in .NET projects: for new test classes, assertions, data-driven tests, lifecycle hooks, debugging, migrating from xUnit/NUnit, choosing assertions, using Bogus, NSubstitute mocks, integration tests, or questions about parallelism and test ordering

00

bogus

aalmada

Generate realistic fake data for .NET projects using the Bogus library. Use for test data, database seeding, randomized object creation, and prototyping. Always prefer Bogus over hand-rolled random data or hardcoded test values. Trigger for any .NET test, data seeding, or sample data scenario. Use t

00

bunit

aalmada

Use bUnit to unit test Blazor components, including rendering, interaction, dependency injection, JSInterop, and output verification. Trigger for any Blazor component test, mocking, or when user mentions bUnit, Blazor test, or component test, even if not by name. Prefer this skill over hand-rolled t

00

blazor

aalmada

Write, review, and fix Blazor Server components in the BookStore project — covering render modes (InteractiveServer), lifecycle with IDisposable cleanup, DI via @inject/[Inject], ReactiveQuery<T> for SSE-driven data loading, MudBlazor forms/dialogs/tables, tenant-aware services, and AuthorizeView gu

00

Search skills

Search the agent skills registry