一键导入
api-design
ASP.NET Core API patterns — Minimal APIs vs Controllers, routing, DTOs, validation, middleware, versioning, ProblemDetails. Auto-loads for API work.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
ASP.NET Core API patterns — Minimal APIs vs Controllers, routing, DTOs, validation, middleware, versioning, ProblemDetails. Auto-loads for API work.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Full-project health audit — spawns 5 specialists (dotnet-reviewer, security-analyzer, testing-reviewer, performance-profiler, deployment-validator) in parallel. Use for onboarding or pre-release.
Analyze project/namespace boundaries, detect circular refs and layering violations via dotnet-depends and solution graph. Use before major refactors or to validate Clean Architecture.
Senior-engineer challenge mode — aggressively question the current approach, hunt for N+1 queries, captive deps, missing auth, sync-over-async, leaks. Use before finalizing significant changes.
Capture a solved problem as institutional knowledge. Writes `.claude/solutions/{category}/{slug}.md` with symptoms, root cause, fix, category, tags. Use after notable fixes.
Generate or update documentation — XML doc comments, README, architecture docs, OpenAPI descriptions. Uses code as source of truth; no hallucinated features.
Extract durable lessons from a just-finished fix — propose CLAUDE.md rule, Iron Law addition, or Solution doc. Use after resolving a surprising/repeatable bug.
| name | api-design |
| description | ASP.NET Core API patterns — Minimal APIs vs Controllers, routing, DTOs, validation, middleware, versioning, ProblemDetails. Auto-loads for API work. |
| effort | medium |
ASP.NET Core Web API design reference.
[Authorize] on all non-public endpoints[ApiController] or FluentValidationAllowAnyOrigin() in prodProblemDetails for errors — never raw exceptionsvar orders = app.MapGroup("/api/v1/orders")
.RequireAuthorization()
.WithTags("Orders");
orders.MapGet("/", async (IOrderService svc, CancellationToken ct) =>
TypedResults.Ok(await svc.ListAsync(ct)))
.Produces<List<OrderDto>>(200);
orders.MapPost("/", async (CreateOrderRequest req, IOrderService svc, CancellationToken ct) =>
{
var dto = await svc.CreateAsync(req, ct);
return TypedResults.Created($"/api/v1/orders/{dto.Id}", dto);
}).Produces<OrderDto>(201).ProducesValidationProblem();
[ApiController]
[Route("api/v1/[controller]")]
[Authorize]
public class OrdersController(IOrderService svc) : ControllerBase
{
[HttpGet("{id:long}")]
[ProducesResponseType(typeof(OrderDto), 200)]
[ProducesResponseType(404)]
public async Task<ActionResult<OrderDto>> Get(long id, CancellationToken ct)
{
var dto = await svc.GetAsync(id, ct);
return dto is null ? NotFound() : Ok(dto);
}
}
public record OrderDto(long Id, Guid CustomerId, decimal Total, string Status);
public record CreateOrderRequest(
[Required] Guid CustomerId,
[MinLength(1)] IReadOnlyList<OrderItemRequest> Items);
UseExceptionHandler → UseHsts → UseHttpsRedirection → UseCors
→ UseAuthentication → UseAuthorization → UseRateLimiter → MapControllers
builder.Services.AddProblemDetails();
app.UseExceptionHandler();
app.UseStatusCodePages();
// Domain → HTTP
app.UseExceptionHandler(ex => ex.Run(async ctx =>
{
var exc = ctx.Features.Get<IExceptionHandlerFeature>()?.Error;
var status = exc switch
{
NotFoundException => 404,
ValidationException => 400,
ConflictException => 409,
_ => 500
};
ctx.Response.StatusCode = status;
await ctx.Response.WriteAsJsonAsync(new ProblemDetails
{
Status = status,
Title = exc?.GetType().Name,
Detail = status == 500 ? "An error occurred" : exc?.Message
});
}));
${CLAUDE_SKILL_DIR}/references/minimal-apis.md — detailed Minimal API
patterns${CLAUDE_SKILL_DIR}/references/controllers.md — controllers, filters,
model binding${CLAUDE_SKILL_DIR}/references/middleware.md — pipeline design${CLAUDE_SKILL_DIR}/references/validation.md — FluentValidation vs
DataAnnotations${CLAUDE_SKILL_DIR}/references/versioning.md — Asp.Versioning package${CLAUDE_SKILL_DIR}/references/openapi.md — .NET 9 AddOpenApi vs
Swashbuckle${CLAUDE_SKILL_DIR}/references/problemdetails.md — RFC 7807
implementationIActionResult when a typed Results<TOk, TError> is available