api-and-interface-design

Designs stable .NET APIs, DTO contracts, and public interfaces with backward compatibility.

7|Updated Jan 11, 2026
One-click install
npx skills add https://github.com/peterblazejewicz/claude-plugins --skill api-and-interface-design-peterblazejewicz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-and-interface-design
Source: https://github.com/peterblazejewicz/claude-plugins/tree/main/plugins/dotnet-skills/skills/api-and-interface-design
Command: npx skills add https://github.com/peterblazejewicz/claude-plugins --skill api-and-interface-design-peterblazejewicz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Public APIs and library interfaces become hard to change once consumers depend on them, and poorly designed contracts lead to breaking changes, inconsistent error handling, and leaked implementation details. This Skill guides the design of stable .NET interfaces so the right thing is easy and the wrong thing is hard. ## Core Features & Use Cases - Contract-first design: Define C# interfaces, records, and DTOs in a MyApp.Contracts assembly before implementation, with mandatory CancellationToken on async methods. - Consistent error semantics: Apply RFC 7807 ProblemDetails conventions for ASP.NET Core endpoints, or choose between exceptions and Result<TSuccess, TError> for libraries. - Boundary validation: Validate external input with FluentValidation, DataAnnotations, or MediatR pipeline behaviors at HTTP, messaging, and configuration edges. - Backward-compatible evolution: Additive-only changes, EF Core migration strategies for non-nullable columns, pagination, PATCH semantics, and strongly-typed IDs with JSON converters. - Use Case: When adding a new Minimal API endpoint backed by EF Core, use this Skill to define the request/response DTOs, validation rules, pagination shape, and error format before writing the handler. ## Quick Start Ask the AI to design a versioned REST endpoint with DTOs, validation, and pagination for a new resource in your ASP.NET Core project.

Frequently Asked Questions about api-and-interface-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a backward-compatible REST API in ASP.NET Core?

Define contracts first as C# records and interfaces, prefer additive changes with optional fields and safe defaults, and use RFC 7807 ProblemDetails for all errors. Paginate list endpoints and cap PageSize server-side so clients cannot request unbounded results.

Should I return EF Core entities directly from API endpoints?

No. Returning DbContext entities makes your database schema the API contract, so every migration becomes a breaking change. Project entities to DTOs in a separate contracts assembly to decouple storage from the public interface.

FluentValidation vs DataAnnotations for ASP.NET Core validation?

FluentValidation suits complex rules and boundary validation in Minimal APIs, while DataAnnotations work for simple cases like Required and MaxLength. MediatR pipeline behaviors are an alternative when validation is a cross-cutting concern.

How do I add a non-nullable column to an existing EF Core table?

Adding a non-nullable column to a populated table fails at migration time. Add it as nullable and backfill first, use HasDefaultValue to seed existing rows, or apply an expand-contract pattern for zero-downtime rollouts.

Why do strongly-typed IDs serialize incorrectly to JSON in .NET?

System.Text.Json treats a readonly record struct ID as an object with a Value property, emitting {"value": "..."} instead of a raw GUID string. Attach a custom JsonConverter to the ID type, or keep plain Guid on the wire and use the struct only in domain code.