api-design

Designs stable, compatible public APIs for C# libraries using extend-only principles.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill api-design-agibuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-design
Source: https://github.com/AGIBuild/dotnet.CI.template/tree/main/.cursor/skills/csharp-api-design
Command: npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill api-design-agibuild

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Public APIs in NuGet packages and distributed systems break consumers when signatures change, members are removed, or wire formats evolve unsafely. This Skill guides you to design APIs that stay source, binary, and wire compatible across versions. ## Core Features & Use Cases - Extend-Only API Design: Enforces rules for adding overloads, optional parameters, and new types without breaking existing callers, including deprecation patterns with [Obsolete]. - Naming, Parameters, and Return Types: Provides conventions for type suffixes, async naming, parameter ordering with CancellationToken last, and choosing between IReadOnlyList, IAsyncEnumerable, and ValueTask. - Wire Compatibility and Versioning: Covers safe serialization evolution, enum strategies, semantic versioning, and API approval testing with PublicApiGenerator. - Use Case: When reviewing a pull request that changes a public method signature, use this Skill to identify the breaking change and produce a safe alternative such as a new overload plus an [Obsolete] attribute. ## Quick Start Ask the assistant to review your public API changes for breaking changes and suggest extend-only alternatives following this Skill's guidelines.

Frequently Asked Questions about api-design

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

FAQPage Schema
How do I change a public C# API without breaking existing consumers?▼

Follow extend-only design: never remove or modify released members, only add new overloads, optional parameters with defaults, or new types. Deprecate old members with [Obsolete] for at least one minor version before removal in a major release.

What return type should a public C# method use for collections?▼

Return IReadOnlyList<T> for materialized collections to signal immutability and indexability. Use IAsyncEnumerable<T> for streaming results and avoid returning mutable collections or ambiguous IEnumerable<T> from public APIs.

Where should CancellationToken go in async method signatures?▼

CancellationToken always goes last in the parameter list, after the target, required parameters, and optional parameters. This ordering is enforced by analyzer rule CA1068 and keeps overload progression consistent.

How do I evolve serialized wire formats without breaking rolling upgrades?▼

Add read-side support for the new format first, then enable the write side in a later release. Use explicit discriminators instead of polymorphic type names, annotate properties with JsonPropertyName, and prefer string enum serialization.

How can I detect accidental breaking API changes in pull requests?▼

Use API approval testing with PublicApiGenerator and a verification framework. The public API surface is snapshot into verified files, so any signature change appears in the PR diff and requires conscious reviewer approval.