Skip to content
Back to skills

Minimal Api Patterns

ASecurity

Builds ASP.NET Core Minimal API routes, route groups, endpoint filters, TypedResults, validation, authorization, and OpenAPI metadata. Use when endpoint mapping is the main task; do not use for MVC/controllers or host-wide middleware (use aspnetcore-patterns) or contract-only compatibility reviews (use api-contract-review).

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentstestingcode-reviewapisecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add k4ndev/claude-code-dotnet --skill minimal-api-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Minimal Api Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Minimal Api Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/k4ndev-minimal-api-patterns/badge)](https://www.skillsdirectory.com/skills/k4ndev-minimal-api-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: minimal-api-patterns
description: Builds ASP.NET Core Minimal API routes, route groups, endpoint filters, TypedResults, validation, authorization, and OpenAPI metadata. Use when endpoint mapping is the main task; do not use for MVC/controllers or host-wide middleware (use aspnetcore-patterns) or contract-only compatibility reviews (use api-contract-review).
---

# Minimal API Patterns

## Purpose
Create discoverable, testable Minimal API endpoints with explicit HTTP contracts, boundary validation, authorization, and cancellation.

## Scope
`MapGet`/`MapPost` route handlers, `MapGroup`, endpoint filters, binding, `TypedResults`, OpenAPI metadata, and API versioning for Minimal API apps.

## When to use
- User asks to build/refactor a Minimal API endpoint or route group.
- The issue concerns handler validation, endpoint authorization, result typing, or route metadata.

## Do not use for
- MVC/controller apps or middleware/DI composition: use `aspnetcore-patterns`.
- HTTP compatibility review without implementation: use `api-contract-review`.
- General guideline review: use `dotnet-code-review`.

## Required context
Check target framework, ASP.NET Core/package versions, endpoint conventions, authentication policies, validation approach, OpenAPI/versioning setup, DTO serialization, DI registrations, and test host.

## Workflow
1. Keep `Program.cs` focused on composition; extract cohesive groups into extension methods when endpoint count/domain warrants it.
2. Define explicit request/response DTOs and validate at the HTTP boundary; do not bind persistence entities directly.
3. Use `MapGroup` for shared route prefixes and metadata. Apply `RequireAuthorization` at group or endpoint scope; make anonymous access explicit.
4. Use `TypedResults` where supported and useful, declaring success/error metadata for generated OpenAPI.
5. Propagate `CancellationToken` into cancellable I/O and avoid unused route parameters or conflicting route patterns.
6. Verify validation behavior against the actual framework/version; do not assume automatic validation that is not configured.
7. Test binding, validation, auth/anonymous paths, status codes, serialization, and OpenAPI contract as appropriate.

## Decision rules
- Use endpoint filters for reusable endpoint-boundary behavior, not as a substitute for business rules.
- Return semantics through HTTP status/result types; avoid ad hoc string errors and broad catch blocks.
- Version APIs only when compatibility policy requires it; verify the installed versioning package/API.

## Expected output format
Show route/group registration, DTO/result types, authorization and validation placement, expected status codes/OpenAPI metadata, and integration-test cases. State framework/package assumptions.

## Common mistakes
- Building a `Program.cs` lambda wall, binding EF entities, omitting authorization metadata, returning undocumented status codes, or ignoring request cancellation.
- Treating endpoint filters as automatic validation or assuming a versioning API exists without checking packages.

## Edge cases
- Route group conventions can be overridden downstream; inspect endpoint metadata in integration tests.
- Optional route values, nullable body fields, enum serialization, and `404` vs `204` are observable contract choices.
- Request cancellation is appropriate for request-scoped work, not necessarily for already-committed durable side effects.

## Examples
See [Minimal API examples](examples.md) for a typed, authorized endpoint with bounded input.

## Test scenarios
- Positive: “Add an authenticated `GET /orders/{id}` Minimal API with 404 and OpenAPI metadata.”
- Negative: “Our MVC middleware order is wrong” routes to `aspnetcore-patterns`.
- Boundary: “Review this Minimal API response for backward compatibility” selects `api-contract-review`, plus `dotnet-code-review` only for full code review.

## Related skills
`aspnetcore-patterns`, `api-contract-review`, `security-audit`, `testing-quality`, `efcore-patterns`.

Files in this skill

  • SKILL.md3.9 KB
  • examples.md1.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.