skills/minimal-api-scaffolder/SKILL.md
Scaffolds .NET 10 Minimal API endpoints with OpenAPI documentation, versioning strategies, and security patterns. Use when creating REST APIs, adding endpoints, setting up API projects, or configuring API infrastructure. Triggers on phrases like "scaffold API", "minimal API", "create endpoint", "API versioning", "api endpoint", "rest endpoint", "add route", "openapi", "create api". Do NOT use when the project is controller-based MVC — use dotnet-vertical-slice for handler architecture instead.
npx skillsauth add michaelalber/ai-toolkit minimal-api-scaffolderInstall 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.
"Minimal APIs are ideal for microservices and apps that want to include only the minimum files, features, and dependencies in ASP.NET Core." -- Microsoft Documentation
"A good API is not just easy to use but also hard to misuse." -- Joshua Bloch
This skill scaffolds and maintains Minimal API endpoints in .NET 10 projects with OpenAPI documentation, versioning, and security configured from the start. Every API begins with a clear contract, validated inputs, and documented responses.
Non-Negotiable Constraints:
.WithName(), .WithSummary(), and .Produces<T>()..RequireAuthorization(). Anonymous access is an explicit opt-in via .AllowAnonymous(), never an implicit default.TypedResults with explicit union return types (Results<Ok<T>, NotFound, ValidationProblem>). No raw IResult, no untyped Results.Ok(), no status code magic numbers.| # | Principle | Description | Priority |
|---|-----------|-------------|----------|
| 1 | Endpoint Grouping | Related endpoints are organized into static extension method classes (e.g., UsersEndpoints). Each group maps a resource to a route prefix with shared tags, authorization, and OpenAPI settings. | Critical |
| 2 | Request/Response Models | All request and response types are C# records. Request models use [AsParameters] for GET queries. No anonymous objects, no dynamic, no Dictionary<string, object>. | Critical |
| 3 | FluentValidation Integration | Every mutating endpoint (POST, PUT, PATCH) injects and executes IValidator<TRequest> before processing. Validation is explicit in the handler, not hidden in middleware. | Critical |
| 4 | OpenAPI Documentation | Every endpoint declares .WithName(), .WithSummary(), .Produces<T>() for all possible status codes, and .Accepts<T>() for request bodies. | Critical |
| 5 | Versioning Strategy | The project chooses a versioning strategy at setup time and applies it consistently. URL versioning (/api/v{version:apiVersion}/) is the recommended default. | High |
| 6 | Authorization Patterns | Endpoint groups default to requiring authorization. Individual endpoints may override with specific policies or .AllowAnonymous(). Policies are defined in Program.cs. | Critical |
| 7 | Rate Limiting | Public and high-traffic endpoints configure rate limiting policies defined as named policies in Program.cs and applied with .RequireRateLimiting(). | High |
| 8 | Error Handling | Errors return RFC 7807 Problem Details via TypedResults.Problem() or TypedResults.ValidationProblem(). A global exception handler produces consistent application/problem+json responses. | High |
| 9 | CORS Configuration | CORS origins are explicitly configured per environment. Never use AllowAnyOrigin() in production. Production must whitelist specific origins loaded from configuration. | High |
| 10 | Health Checks | Every API project includes health check endpoints (/health, /health/ready, /health/live) mapped with .AllowAnonymous(). Database connectivity is included in readiness checks. | Medium |
| Query | When to Call |
|-------|--------------|
| search_knowledge("ASP.NET Core Minimal API endpoint group TypedResults .NET 10") | At SCAFFOLD phase — confirms current Minimal API patterns and TypedResults syntax |
| search_knowledge("ASP.NET Core API versioning URL header query string") | During CONFIGURE phase — authoritative versioning strategies and setup |
| search_knowledge("ASP.NET Core authentication JWT bearer authorization policy") | During SECURE phase — confirms authentication pipeline and policy setup |
| search_knowledge("OpenAPI Swagger ASP.NET Core endpoint metadata WithName Produces") | During DOCUMENT phase — authoritative OpenAPI metadata decoration patterns |
| search_knowledge("ASP.NET Core rate limiting policy RequireRateLimiting") | When configuring rate limiting — confirms rate limiter registration and application |
| search_knowledge("ASP.NET Core health checks ready live endpoints") | When scaffolding health checks — confirms health check endpoint patterns |
Search before each scaffold phase. Generated code must use KB-confirmed API signatures — never training-data assumptions about .NET versioned APIs. Cite source paths in generated file headers.
The scaffold lifecycle flows: CONFIGURE → SCAFFOLD → SECURE → DOCUMENT. Each phase has a verification checklist before advancing to the next.
Set up the project foundation before any endpoints are created.
.csproj with required packages (see references/endpoint-patterns.md)Program.cs with service registrations: OpenAPI, versioning, FreeMediator, FluentValidation, DbContextCreate endpoint groups, request/response models, and validators.
Program.cs via api.Map{Resource}Endpoints()Apply authorization, rate limiting, and CORS to all endpoints.
.RequireAuthorization() to endpoint groupsEnsure every endpoint is fully documented via OpenAPI metadata.
.WithName() and .WithSummary().Produces<T>() responses.WithDescription() for complex endpoints<api-scaffold-state>
mode: SCAFFOLD
project_name: MyApp.Api
dotnet_version: net10.0
endpoints_created: [UsersEndpoints]
versioning_strategy: url
auth_configured: true
openapi_configured: true
last_action: Scaffolded UsersEndpoints with full CRUD
next_action: Create OrdersEndpoints group
</api-scaffold-state>
## API Project: [Name] | .NET 10 | Versioning: [URL/Header/Query] | Auth: [JWT/Azure AD]
Packages: Swashbuckle, Asp.Versioning.Http, FluentValidation, FreeMediator
## Endpoint Group: [Resource]
Base Path: /api/v{version}/[resource] | Auth: Required | Rate Limited: [Yes/No]
| Method | Path | Name | Request Type | Response Type | Auth Override |
| GET / | GET /{id} | POST / | PUT /{id} | DELETE /{id} |
Error responses: 400 Validation | 401 Auth | 403 Forbidden | 404 Not Found | 500 Server Error
Full templates (Project Setup Checklist with packages, Endpoint Group Report with request/response schemas, Validation Report, API Documentation Summary): references/endpoint-patterns.md
Always add FluentValidation to mutating endpoints. Every POST, PUT, and PATCH handler must inject IValidator<TRequest>, call ValidateAsync() before any business logic, and return TypedResults.ValidationProblem(validation.ToDictionary()) on failure. The return type must be a union type — Results<Created<T>, ValidationProblem> — not raw IResult. Never rely on model binding validation alone.
Never create endpoints without OpenAPI metadata. Every endpoint must have .WithName("OperationId"), .WithSummary("brief description"), .Produces<T>(statusCode) for every possible response, and .Accepts<T>() for request bodies. An endpoint without this metadata is invisible to API consumers and tooling.
Always configure CORS explicitly per environment. Never use AllowAnyOrigin() outside development. Origins must be loaded from configuration, not hardcoded. Apply CORS in the middleware pipeline before authentication. Allow credentials only when specific origins are listed.
Use TypedResults with union return types. All handlers must return TypedResults with explicit union types declared in the method signature (Results<Ok<UserDto>, NotFound>). No raw strings, magic status codes, or untyped IResult in endpoint bodies.
Enforce structural versioning and one group per resource. Version segments must appear in the route template — use app.NewVersionedApi() with .HasApiVersion() on groups. One Map{Resource}Endpoints() extension method per resource, called from a single location in Program.cs. When a breaking change occurs, create a new version-specific endpoint class; never add conditional logic inside an existing handler.
| # | Anti-Pattern | Problem | Correct Approach |
|---|-------------|---------|------------------|
| 1 | Fat Program.cs | All registrations and middleware in one massive file | Extract endpoint groups to static extension classes |
| 2 | Endpoints Without Validation | Request data flows directly to business logic without validation | Always inject and call IValidator<T> in mutating endpoints |
| 3 | Missing OpenAPI Tags | Endpoints appear ungrouped in Swagger UI, making the API undiscoverable | Apply .WithTags() at group level, .WithName()/.WithSummary() on every endpoint |
| 4 | Hardcoded CORS Origins | Origins embedded in Program.cs cannot change per environment | Load origins from appsettings.json or environment variables |
| 5 | No Versioning Strategy | API changes break existing clients with no migration path | Configure versioning at project creation; use URL versioning as default |
| 6 | Mixing Controllers and Minimal APIs | Two routing systems in one project create confusion about conventions | Choose one approach per project |
| 7 | Returning Raw Strings | Results.Ok("success") provides no type safety and no OpenAPI schema | Use TypedResults.Ok(typedObject) with strongly typed response records |
| 8 | Catch-All Exception Handlers in Endpoints | try/catch in every handler duplicates error handling logic | Use global exception handler middleware; let exceptions propagate |
| 9 | Anonymous Endpoints by Default | Forgetting .RequireAuthorization() leaves endpoints publicly accessible | Apply auth at the group level; .AllowAnonymous() as explicit opt-in |
| 10 | Inline Lambda Handlers | Complex logic inside MapGet("/", async (ctx) => {...}) is untestable | Extract handlers to named static methods; inject dependencies as parameters |
Project already has controllers: Do NOT convert existing controllers in place. Create a Features/ directory alongside existing Controllers/. Configure both app.MapControllers() and minimal API groups in Program.cs. Migrate one resource at a time — create the minimal API endpoint group, verify it works, then deprecate the controller. Ask the developer before mixing paradigms; a gradual migration is acceptable, a hybrid architecture with no migration plan is not.
Conflicting versioning approaches (URL in some places, header in others): Identify the dominant strategy already in use. Configure ApiVersionReader.Combine() to support existing clients during migration. Standardize all new endpoints on URL versioning. Document the canonical approach. Never remove a working version reader without a client migration plan.
OpenAPI generation failures (Swagger UI fails or shows missing schemas): Check for endpoints missing .Produces<T>() — Swashbuckle cannot infer response types from minimal APIs. Verify all response types are public records (internal types are invisible). Check for duplicate .WithName() values (operation IDs must be unique). Inspect /swagger/v1/swagger.json directly for schema errors. Verify app.UseSwagger() and app.UseSwaggerUI() are in the correct pipeline order.
Rate limiting not taking effect: Verify app.UseRateLimiter() is in the pipeline after routing and before auth. Confirm rate limiter policy names match the names used in .RequireRateLimiting("PolicyName"). Test under load with bombardier or hey. Verify the OnRejected handler returns 429 responses.
| Skill | Integration Point | When to Use |
|-------|-------------------|-------------|
| dotnet-vertical-slice | Feature architecture for handlers behind endpoints | Scaffold CQRS handlers, commands, queries, and validators that endpoint groups delegate to |
| dotnet-architecture-checklist | Review scaffolded API projects | Run after scaffolding to verify architectural best practices |
| test-scaffold | Generate API integration tests | Create test classes exercising endpoints via WebApplicationFactory<Program> |
| dotnet-security-review | Security audit of API configuration | Verify JWT configuration, authorization policies, CORS settings, and rate limiting |
| ef-migration-manager | Database setup for API data access | Use when endpoints need new entities or schema changes |
References: references/endpoint-patterns.md (full endpoint group templates, request models, validators, OpenAPI patterns, error handling) | references/versioning-strategies.md (URL/header/query versioning with deprecation) | references/security-patterns.md (authorization, rate limiting, CORS, health checks, JWT setup)
development
Interviews the user relentlessly about a plan, decision, or idea — one question at a time, each with a recommended answer. Shared engine behind "grill-me" and "grill-with-docs". Use on any "grill" trigger phrase or to stress-test thinking. Do NOT use to build the plan; it ends at shared understanding, not implementation.
testing
Runs a relentless interview to sharpen a plan or design, capturing the decisions as ADRs and a glossary along the way. Use when the user wants to be grilled AND wants the session to leave durable domain documentation behind. Do NOT use for a throwaway stress-test with no artifacts; use grill-me instead.
tools
OWASP-based security review of Vue/TypeScript front-ends. Detects framework (Vite/Vue CLI/Nuxt), entry points, and data flows; scans the OWASP Top 10 (2025) mapped to Vue client-side risks (raw-HTML XSS via v-html, URL/protocol injection, bundled secrets, insecure token storage, dependency CVEs, missing CSP, open redirects, router guard bypass); emits an exec summary plus graded findings. Use to audit Vue for vulnerabilities. Not for architecture grading (vue-architecture-checklist).
tools
Analyzes legacy Vue codebases and produces actionable modernization plans. Primary migration paths include Options API to Composition API, Vue 2 to Vue 3, Vue CLI to Vite, JavaScript to TypeScript, Vue Test Utils/Karma/Mocha to Vitest + Vue Testing Library, legacy Vuex to Pinia, and removed-in-Vue-3 pattern cleanup (filters, event bus, `$listeners`). Does NOT perform the migration — assesses, quantifies risk, and plans.