aspnet-minimal-apis
A guide for organizing and implementing clean, maintainable Minimal APIs in ASP.NET Core using modern best practices.
Install
mkdir -p .claude/skills/aspnet-minimal-apis && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16625" && unzip -o skill.zip -d .claude/skills/aspnet-minimal-apis && rm skill.zipInstalls to .claude/skills/aspnet-minimal-apis
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.
Structure, organize, and extend ASP.NET Core Minimal APIs using route groups, parameter binding, endpoint metadata, and filters — without controllers. Covers MapGroup with RouteGroupBuilder extension methods, all binding sources ([FromBody], [FromServices], [FromRoute], [AsParameters]), endpoint conventions (WithName, WithSummary, WithTags, RequireAuthorization, ExcludeFromDescription), endpoint filters, and the static-class/named-method organization pattern. Trigger whenever the user writes, reviews, or asks about Minimal API routing, route groups, parameter binding, endpoint registration, MapGet/MapPost/MapPut/MapDelete, IEndpointRouteBuilder, RouteGroupBuilder, [AsParameters], DI in handlers, or organizing Minimal API endpoints — even if they don't mention these terms by name. Always prefer this skill over guessing; the binding and group APIs have subtle rules that are easy to get wrong.Key capabilities
- →Structure Minimal APIs using route groups
- →Organize endpoints with `RouteGroupBuilder` extension methods
- →Configure parameter binding for Minimal APIs
- →Apply endpoint metadata like `WithName` and `WithSummary`
- →Implement endpoint filters for cross-cutting logic
- →Organize endpoints using the static-class/named-method pattern
How it works
This skill provides patterns and rules for structuring ASP.NET Core Minimal APIs using route groups, parameter binding, endpoint metadata, and filters to maintain scalability and testability.
Inputs & outputs
When to use aspnet-minimal-apis
- →Organize endpoints using MapGroup
- →Configure parameter binding for APIs
- →Add OpenApi metadata to minimal endpoints
- →Implement endpoint filters for cross-cutting logic
About this skill
ASP.NET Core Minimal APIs Skill
Minimal APIs let you define HTTP endpoints directly in C# without controllers, using a functional style that's concise, composable, and easy to test. The key to keeping them maintainable at scale is to apply a consistent organization pattern from the start.
Why this matters
The default inline-lambda style works for small APIs but quickly becomes unwieldy. Route groups, named handler methods, and RouteGroupBuilder extension methods give you the structure of controllers without the ceremony — and they're the prerequisite for TypedResults to work properly (see aspnet-typed-results for response types) and for OpenAPI to self-document (see aspnet-openapi).
Quick reference
| Topic | See |
|---|---|
Route groups, MapGroup, RouteGroupBuilder extension methods, nesting | route-groups.md |
Binding: route, query, body, DI, headers, [AsParameters], special types | parameter-binding.md |
WithName, WithSummary, WithTags, RequireAuthorization, ExcludeFromDescription, Accepts | endpoint-metadata.md |
IEndpointFilter, filter factories, filter ordering | filters.md |
| Common mistakes | pitfalls.md |
The standard organization pattern
Define a static class per feature area. Expose a single extension method on RouteGroupBuilder that registers all routes. Keep handler methods as private static or internal static named methods below the registration method.
public static class ProductEndpoints
{
// Called from Program.cs or a central mapping extension
public static RouteGroupBuilder MapProductEndpoints(this RouteGroupBuilder group)
{
_ = group.MapGet("/", GetProducts)
.WithName("GetProducts")
.WithSummary("List all products");
_ = group.MapGet("/{id:guid}", GetProduct)
.WithName("GetProduct")
.WithSummary("Get a product by ID");
_ = group.MapPost("/", CreateProduct)
.WithName("CreateProduct")
.WithSummary("Create a new product")
.RequireAuthorization();
return group;
}
// Handler methods: named, static, directly callable in unit tests
static async Task<Ok<ProductDto[]>> GetProducts(
[FromServices] IDocumentSession session,
CancellationToken cancellationToken) =>
TypedResults.Ok(await session.Query<ProductDto>().ToArrayAsync(cancellationToken));
static async Task<Results<Ok<ProductDto>, NotFound>> GetProduct(
Guid id,
[FromServices] IDocumentSession session,
CancellationToken cancellationToken)
{
var product = await session.LoadAsync<ProductDto>(id, cancellationToken);
return product is null ? TypedResults.NotFound() : TypedResults.Ok(product);
}
static async Task<Created<ProductDto>> CreateProduct(
[FromBody] CreateProductRequest request,
[FromServices] IMessageBus bus,
CancellationToken cancellationToken)
{
var product = await bus.InvokeAsync<ProductDto>(new CreateProductCommand(request), cancellationToken);
return TypedResults.Created($"/api/products/{product.Id}", product);
}
}
Register centrally in Program.cs:
app.MapGroup("/api/products")
.WithTags("Products")
.MapProductEndpoints();
Essential rules at a glance
- Extract handler methods — inline lambdas can't return
Results<T1,T2>and can't be unit-tested directly. - Group at the call site — prefix, tags, auth, and API versioning belong on the outer group, not inside the endpoint class.
[FromServices]for DI — service parameters are not injected automatically unless marked; use[FromServices](orFromKeyedServices) to be explicit.[AsParameters]— wraps multiple query/route/header params into a single record for clean large parameter lists.- Route constraints —
{id:guid},{page:int:min(1)}prevent bad input from reaching the handler. CancellationToken— always accept it in async handlers; it's bound automatically from the request without any attribute.
What to read next
- Organising multiple groups and nesting → route-groups.md
- Binding from query strings, headers, forms, or custom types → parameter-binding.md
- Applying auth, rate limiting, metadata → endpoint-metadata.md
- Cross-cutting logic without middleware → filters.md
- Unexpected 404s, binding failures, or wrong DI injection → pitfalls.md
When not to use it
- →When using traditional ASP.NET Core controllers
- →When the API is very small and inline lambdas are sufficient
Limitations
- →The skill focuses on Minimal APIs, not traditional controllers.
- →Inline lambdas become unwieldy for larger APIs.
How it compares
This skill offers a structured approach to building Minimal APIs without controllers, providing organization and maintainability beyond simple inline lambdas.
Compared to similar skills
aspnet-minimal-apis side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| aspnet-minimal-apis (this skill) | 0 | 4mo | No flags | Advanced |
| dotnet-backend-patterns | 7 | 5mo | No flags | Advanced |
| azure-servicebus-dotnet | 3 | 3mo | Review | Intermediate |
| azure-eventgrid-dotnet | 1 | 3mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by aalmada
View all by aalmada →You might also like
dotnet-backend-patterns
wshobson
Master C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.
azure-servicebus-dotnet
microsoft
Azure Service Bus SDK for .NET. Enterprise messaging with queues, topics, subscriptions, and sessions. Use for reliable message delivery, pub/sub patterns, dead letter handling, and background processing. Triggers: "Service Bus", "ServiceBusClient", "ServiceBusSender", "ServiceBusReceiver", "ServiceBusProcessor", "message queue", "pub/sub .NET", "dead letter queue".
azure-eventgrid-dotnet
microsoft
Azure Event Grid SDK for .NET. Client library for publishing and consuming events with Azure Event Grid. Use for event-driven architectures, pub/sub messaging, CloudEvents, and EventGridEvents. Triggers: "Event Grid", "EventGridPublisherClient", "CloudEvent", "EventGridEvent", "publish events .NET", "event-driven", "pub/sub".
websocket-integration
sunyonghuan
通过 WebSocket 连接 Cortana AI 对话服务。编写 C# 客户端代码,实现发送消息、接收流式回复、附件传输、系统事件监听。触发关键词:WebSocket、WS 连接、远程对话、流式回复、AI 接入、实时通信。
mediatorlite-core
behl1anmol
Runtime implementation for MediatorLite -- AddMediatorLite() DI extension, the ThrowingMediator diagnostic fallback, the generated SourceGeneratedMediator (implements IMediator via ValueTask typed-switch dispatch), MediatorDiagnostics (ActivitySource + DiagnosticListener), and the Validation subsyst
azure-ai-voicelive-dotnet
wegonbeok45
Azure AI Voice Live SDK for .NET. Build real-time voice AI applications with bidirectional WebSocket communication.