/dotnet-webapi
Guides creation and modification of ASP.NET Core Web API endpoints with correct HTTP semantics, OpenAPI metadata, and error handling. USE FOR: adding new API endpoints (controllers or minimal APIs), wiring up OpenAPI/Swagger, creating .http test files, setting up global error
$ npx -y skills add managedcode/dotnet-skills --skill dotnet-webapi --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/dotnet-webapi
Context preview
The summary Claude sees to decide when to auto-load this skill.
Guides creation and modification of ASP.NET Core Web API endpoints with correct HTTP semantics, OpenAPI metadata, and error handling. USE FOR: adding new API endpoints (controllers or minimal APIs), wiring up OpenAPI/Swagger, creating .http test files, setting up global error
SKILL.md
dotnet-webapi.SKILL.mdname: dotnet-webapi
description: >
Guides creation and modification of ASP.NET Core Web API endpoints with
correct HTTP semantics, OpenAPI metadata, and error handling.
USE FOR: adding new API endpoints (controllers or minimal APIs), wiring up
OpenAPI/Swagger, creating .http test files, setting up global error handling
middleware.
DO NOT USE FOR: general C# coding style, EF Core data access or query
optimization (use optimizing-ef-core-queries), frontend/Blazor work, gRPC
services, or SignalR hubs.
license: MIT
ASP.NET Core Web API
Produce well-structured ASP.NET Core Web API endpoints with proper HTTP semantics, OpenAPI documentation, and error handling.
When to Use
Use this skill when working on ASP.NET Core HTTP APIs, including:
- adding or modifying Web API endpoints implemented with controllers or minimal APIs;
- wiring up OpenAPI/Swagger metadata and endpoint documentation;
- defining request/response DTOs and consistent HTTP status code behavior;
- adding `.http` files or similar request-based API testing artifacts;
- configuring centralized API error handling middleware or exception mapping.
When Not to Use
Do not use this skill for:
- general C# coding style or non-API refactoring;
- EF Core data modeling or query optimization work; use `optimizing-ef-core-queries`;
- frontend, Razor, or Blazor UI changes;
- gRPC services;
- SignalR hubs or real-time messaging flows.
Inputs / prerequisites
Before applying this skill, gather the project context needed to match the existing API style and wiring:
- the ASP.NET Core entry point, typically `Program.cs`;
- any existing controllers, especially classes inheriting `ControllerBase` or
using `[ApiController]`;
- any existing minimal API registrations such as `app.MapGet`, `app.MapPost`,
`app.MapPut`, or `app.MapDelete`;
- related DTO, model, validation, and error-handling types already used by the project;
- available build, run, and test commands so changes can be verified.
If the user asks for a new endpoint, inspect the current project structure first so the implementation follows the established conventions rather than mixing styles.
Workflow
Step 1: Determine the API style
Scan the project for existing endpoint patterns before writing any code.
1. Search for classes inheriting `ControllerBase` or decorated with `[ApiController]`. 2. Search `Program.cs` or endpoint files for `app.MapGet`, `app.MapPost`, etc. 3. If the project already uses **controllers**, continue with controllers. 4. If the project already uses **minimal APIs**, continue with minimal APIs. 5. If neither exists (new project), **default to minimal APIs** unless the user explicitly requests controllers.
Do not mix styles in the same project.
Step 2: Define request and response types
Create dedicated types for API input and output. Never expose EF Core entities directly in request or response bodies.
**Use `sealed record` for all DTOs.** Records enforce immutability, provide value-based equality, and produce concise code. Seal them to prevent unintended inheritance and enable JIT devirtualization (CA1852).
**Naming convention:**
| Role | Convention | Example | |------|-----------|---------| | Input (create) | `Create{Entity}Request` | `CreateProductRequest` | | Input (update) | `Update{Entity}Request` | `UpdateProductRequest` | | Output (single) | `{Entity}Response` | `ProductResponse` | | Output (list) | `{Entity}ListResponse` | `ProductListResponse` |
**XML doc comments on all DTOs:** Add `<summary>` XML doc comments to every request and response type exposed in the API. These comments are automatically included in the generated OpenAPI specification, producing richer documentation without extra metadata calls.
Reference: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/openapi-comments
**Date and time values — use `DateTimeOffset`:** When a DTO includes a date or time property, always use `DateTimeOffset` instead of `DateTime`. `DateTimeOffset` preserves the UTC offset, avoids ambiguous timezone conversions, and serializes to ISO 8601 with offset information in JSON — which is what API consumers expect.
Reference: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset **JSON serialization options — preserve existing behavior by default:** For existing APIs, do **not** introduce stricter serialization/deserialization settings unless the project already uses them or the user explicitly asks for them. Settings such as case-sensitive property matching and strict number handling can break existing clients. For **new projects**, or when strict JSON handling is explicitly requested, configure options like the following to minimize the potential of processing malicious requests:
// Apply these settings only for new projects, when the existing project already
// uses them, or when the user explicitly requests stricter JSON behavior.
builder.Services.ConfigureHttpJsonOptions(options =>
{
// disallow reading numbers from JSON strings
options.SerializerOptions.NumberHandling = JsonNumberHandling.Strict;
// match properties with exact casing during deserialization
options.SerializerOptions.PropertyNameCaseInsensitive = false;
// reject duplicate JSON property names during deserialization
options.SerializerOptions.AllowDuplicateProperties = false;
// omit null properties from serialized output
options.SerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});**Enum properties — serialize as strings by default:** Unless the user explicitly requests integer serialization, all enum properties should be serialized as strings. String-serialized enums are human-readable, less fragile when values are reordered, and produce better OpenAPI documentation. See Step 4 for the `JsonStringEnumConverter` configuration.
**Response DTOs** — use positional sealed records for concise, immutable output:
/// <summ
Read more
name: dotnet-webapi description: > Guides creation and modification of ASP.NET Core Web API endpoints with correct HTTP semantics, OpenAPI metadata, and error handling. USE FOR: adding new API endpoints (controllers or minimal APIs), wiring up OpenAPI/Swagger, creating .http test files, setting up global error handling middleware. DO NOT USE FOR: general C# coding style, EF Core data access or query optimization (use optimizing-ef-core-queries), frontend/Blazor work, gRPC services, or SignalR hubs. license: MIT
ASP.NET Core Web API
Produce well-structured ASP.NET Core Web API endpoints with proper HTTP semantics, OpenAPI documentation, and error handling.
When to Use
Use this skill when working on ASP.NET Core HTTP APIs, including:
- adding or modifying Web API endpoints implemented with controllers or minimal APIs;
- wiring up OpenAPI/Swagger metadata and endpoint documentation;
- defining request/response DTOs and consistent HTTP status code behavior;
- adding `.http` files or similar request-based API testing artifacts;
- configuring centralized API error handling middleware or exception mapping.
When Not to Use
Do not use this skill for:
- general C# coding style or non-API refactoring;
- EF Core data modeling or query optimization work; use `optimizing-ef-core-queries`;
- frontend, Razor, or Blazor UI changes;
- gRPC services;
- SignalR hubs or real-time messaging flows.
Inputs / prerequisites
Before applying this skill, gather the project context needed to match the existing API style and wiring:
- the ASP.NET Core entry point, typically `Program.cs`;
- any existing controllers, especially classes inheriting `ControllerBase` or
using `[ApiController]`;
- any existing minimal API registrations such as `app.MapGet`, `app.MapPost`,
`app.MapPut`, or `app.MapDelete`;
- related DTO, model, validation, and error-handling types already used by the project;
- available build, run, and test commands so changes can be verified.
If the user asks for a new endpoint, inspect the current project structure first so the implementation follows the established conventions rather than mixing styles.
Workflow
Step 1: Determine the API style
Scan the project for existing endpoint patterns before writing any code.
1. Search for classes inheriting `ControllerBase` or decorated with `[ApiController]`. 2. Search `Program.cs` or endpoint files for `app.MapGet`, `app.MapPost`, etc. 3. If the project already uses **controllers**, continue with controllers. 4. If the project already uses **minimal APIs**, continue with minimal APIs. 5. If neither exists (new project), **default to minimal APIs** unless the user explicitly requests controllers.
Do not mix styles in the same project.
Step 2: Define request and response types
Create dedicated types for API input and output. Never expose EF Core entities directly in request or response bodies.
**Use `sealed record` for all DTOs.** Records enforce immutability, provide value-based equality, and produce concise code. Seal them to prevent unintended inheritance and enable JIT devirtualization (CA1852).
**Naming convention:**
| Role | Convention | Example | |------|-----------|---------| | Input (create) | `Create{Entity}Request` | `CreateProductRequest` | | Input (update) | `Update{Entity}Request` | `UpdateProductRequest` | | Output (single) | `{Entity}Response` | `ProductResponse` | | Output (list) | `{Entity}ListResponse` | `ProductListResponse` |
**XML doc comments on all DTOs:** Add `<summary>` XML doc comments to every request and response type exposed in the API. These comments are automatically included in the generated OpenAPI specification, producing richer documentation without extra metadata calls.
Reference: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/openapi-comments
**Date and time values — use `DateTimeOffset`:** When a DTO includes a date or time property, always use `DateTimeOffset` instead of `DateTime`. `DateTimeOffset` preserves the UTC offset, avoids ambiguous timezone conversions, and serializes to ISO 8601 with offset information in JSON — which is what API consumers expect.
Reference: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset **JSON serialization options — preserve existing behavior by default:** For existing APIs, do **not** introduce stricter serialization/deserialization settings unless the project already uses them or the user explicitly asks for them. Settings such as case-sensitive property matching and strict number handling can break existing clients. For **new projects**, or when strict JSON handling is explicitly requested, configure options like the following to minimize the potential of processing malicious requests:
// Apply these settings only for new projects, when the existing project already
// uses them, or when the user explicitly requests stricter JSON behavior.
builder.Services.ConfigureHttpJsonOptions(options =>
{
// disallow reading numbers from JSON strings
options.SerializerOptions.NumberHandling = JsonNumberHandling.Strict;
// match properties with exact casing during deserialization
options.SerializerOptions.PropertyNameCaseInsensitive = false;
// reject duplicate JSON property names during deserialization
options.SerializerOptions.AllowDuplicateProperties = false;
// omit null properties from serialized output
options.SerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});**Enum properties — serialize as strings by default:** Unless the user explicitly requests integer serialization, all enum properties should be serialized as strings. String-serialized enums are human-readable, less fragile when values are reordered, and produce better OpenAPI documentation. See Step 4 for the `JsonStringEnumConverter` configuration.
**Response DTOs** — use positional sealed records for concise, immutable output:
/// <summ
Stop explaining .NET to your AI. Start building. We've all been there: asking Claude to use Entity Framework, only to get EF6 patterns in a .NET 8 project. Explaining to Copilot that Blazor Server and Blazor WebAssembly aren't the same thing.
Repo: managedcode/dotnet-skills
Other skills on dotnet-skills.
- /aspnet-core
Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on current .NET. USE FOR: working on ASP.NET Core apps, services, or middleware; changing auth, routing, configuration,
Open skill - /aspire
Build, upgrade, and operate Aspire 13.4.x C# or TypeScript application hosts with the current CLI, AppHost, ServiceDefaults, integrations, dashboard, testing, MCP, and deployment patterns for distributed apps. USE FOR: Aspire.AppHost.Sdk, Aspire.Hosting.*,
Open skill - /azure-functions
Build, review, or migrate Azure Functions in .NET with correct execution model, isolated worker setup, bindings, DI, and Durable Functions patterns. USE FOR: working on Azure Functions in .NET; migrating from the in-process model to the isolated worker model; adding Durable
Open skill - /blazor
Build and review Blazor applications across server, WebAssembly, web app, and hybrid scenarios with correct component design, state flow, rendering, and hosting choices. USE FOR: building interactive web UIs with C# instead of JavaScript; choosing between Server, WebAssembly, or
Open skill - /entity-framework6
Maintain or migrate EF6-based applications with realistic guidance on what to keep, what to modernize, and when EF Core is or is not the right next step. USE FOR: EF6 codebases; runtime versus ORM migration decisions; EDMX, code-first, ObjectContext, and legacy data-access
Open skill - /entity-framework-core
Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications. USE FOR: DbContext, migrations, model configuration, EF queries, tracking, loading, performance, transactions, and
Open skill

