roninforge/roninforge-aspnet/aspnet-new-minimal-api

Claude Code and agent skill by roninforge/roninforge-aspnet

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Scaffold an ASP.NET Core 9 Minimal API endpoint group: record DTOs with validation, MapGroup with RequireAuthorization, TypedResults for compile-time response typing, AsNoTracking + projection, CancellationToken propagation, ProblemDetails, OpenAPI.

Install

npx vskill@latest install roninforge/roninforge-aspnet/aspnet-new-minimal-api

SKILL.md

The same SKILL.md was published earlier as roninforge/roninforge-aspnet/aspnet-new-minimal-api.

Scaffold ASP.NET Core 9 Minimal API Endpoint Group

When to Use

When creating a new endpoint group (e.g. /api/orders) on a Minimal-API-based service, or rewriting controller-based endpoints to the Minimal API style.

Instructions

  1. Pick the resource name and routes (e.g. Order: GET list, GET by id, POST create).
  1. Create the request DTO as a sealed record with validation attributes:

``csharp public sealed record CreateOrder( [Required, StringLength(64)] string Sku, [Range(1, 1000)] int Quantity); ``

  1. Create the response DTO as a sealed record:

``csharp public sealed record OrderDto(int Id, string Sku, int Quantity, decimal Total, DateTime CreatedAt); ``

  1. Create an endpoints class with a static extension method that maps the group:

```csharp public static class OrdersEndpoints { public static IEndpointRouteBuilder MapOrdersEndpoints(this IEndpointRouteBuilder app) { var g = app.MapGroup("/api/orders") .RequireAuthorization() .WithTags("Orders");

g.MapGet("/{id:int}", GetById).WithName("GetOrderById"); g.MapGet("/", List).WithName("ListOrders"); g.MapPost("/", Create).WithName("CreateOrder");

return app; }

private static async Task<Results<Ok<OrderDto>, NotFound>> GetById( int id, AppDb db, CancellationToken ct) { var dto = await db.Orders.AsNoTracking() .Where(o => o.Id == id) .Select(o => new OrderDto(o.Id, o.Sku, o.Quantity, o.Total, o.CreatedAt)) .FirstOrDefaultAsync(ct); return dto is null ? TypedResults.NotFound() : TypedResults.Ok(dto); }

private static async Task<Ok<List<OrderDto>>> List( AppDb db, CancellationToken ct, [FromQuery] int page = 1, [FromQuery] int size = 25) { var dtos = await db.Orders.AsNoTracking() .OrderByDescending(o => o.CreatedAt) .Skip((page - 1) * size).Take(size) .Select(o => new OrderDto(o.Id, o.Sku, o.Quantity, o.Total, o.CreatedAt)) .ToListAsync(ct); return TypedResults.Ok(dtos); }

private static async Task<Results<Created<OrderDto>, ValidationProblem>> Create( CreateOrder req, AppDb db, CancellationToken ct) { var order = new Order { Sku = req.Sku, Quantity = req.Quantity, Total = req.Quantity * 9.99m }; db.Orders.Add(order); await db.SaveChangesAsync(ct); var dto = new OrderDto(order.Id, order.Sku, order.Quantity, order.Total, order.CreatedAt); return TypedResults.Created($"/api/orders/{order.Id}", dto); } } ```

  1. Wire the group into Program.cs:

``csharp app.MapOrdersEndpoints(); ``

  1. If validation is needed beyond data annotations, add an endpoint filter:

``csharp g.MapPost("/", Create).AddEndpointFilter<ValidationFilter<CreateOrder>>(); ``

Where ValidationFilter<T> runs MiniValidation.TryValidate(req, out var errs) and returns TypedResults.ValidationProblem(errs) on failure.

  1. Ensure Program.cs has AddProblemDetails(), UseExceptionHandler(), UseStatusCodePages(), and AddOpenApi() + MapOpenApi().
  1. Write a WebApplicationFactory<Program>-based test (see aspnet-testing.mdc for the pattern).

Anti-patterns to avoid

  • Never return IActionResult or Task<IActionResult> from a Minimal API handler.
  • Never return the entity (Order) directly; always project to a record DTO.
  • Never use db.Orders.ToList() (sync) - always ToListAsync(ct).
  • Never instantiate new HttpClient() inside a handler - inject a typed client.
  • Always include CancellationToken ct as a parameter and pass it through every async call.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/roninforge/roninforge-aspnet/aspnet-new-minimal-api/badge)](https://verified-skill.com/skills/roninforge/roninforge-aspnet/aspnet-new-minimal-api)

Something wrong with this skill or its page? Tell us.