.claude/skills/api-versioning-strategy/SKILL.md
Use when adding versioning to HTTP APIs, introducing a breaking change to an existing API contract, or when you need to deprecate an old API version with a sunset protocol. Covers URL segment, query string, header, and media type strategies, Asp.Versioning setup, deprecation headers with Sunset dates, and breaking vs. additive change classification rules. Domain: API Design, REST. Level: Intermediate. Tags: api-versioning, rest, breaking-changes, deprecation, minimal-api.
npx skillsauth add klod68/littlerae api-versioning-strategyInstall 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.
APIs evolve over time. Without explicit versioning, breaking changes cause consumer failures, and teams resort to ad-hoc workarounds like V2 suffixes on endpoints or parallel controllers.
Select a versioning strategy based on your API's audience. Default unversioned requests to the latest stable version. Deprecate old versions with headers and sunset dates.
| Strategy | URL Shape | Pros | Cons | Best For |
|----------|-----------|------|------|----------|
| URL Segment | /api/v1/orders | Simple, visible, cacheable | URL changes on version bump | Public APIs, REST |
| Query String | /api/orders?api-version=1.0 | URL stable, easy to add | Easy to forget, less visible | Internal APIs |
| Header | X-Api-Version: 1.0 | Clean URLs, no routing changes | Invisible, harder to test | Internal microservices |
| Media Type | Accept: application/vnd.myapp.v1+json | RESTful, content negotiation | Complex, harder to document | Hypermedia APIs |
<PackageReference Include="Asp.Versioning.Http" Version="8.1.0" />
<!-- For MVC: Asp.Versioning.Mvc -->
<!-- For MVC + API Explorer: Asp.Versioning.Mvc.ApiExplorer -->
builder.Services.AddApiVersioning(options =>
{
options.DefaultApiVersion = new ApiVersion(1, 0);
options.AssumeDefaultVersionWhenUnspecified = true;
options.ReportApiVersions = true; // Adds api-supported-versions header
options.ApiVersionReader = ApiVersionReader.Combine(
new UrlSegmentApiVersionReader(),
new HeaderApiVersionReader("X-Api-Version")
);
});
var versionSet = app.NewApiVersionSet()
.HasApiVersion(new ApiVersion(1, 0))
.HasApiVersion(new ApiVersion(2, 0))
.HasDeprecatedApiVersion(new ApiVersion(1, 0))
.Build();
var v1 = app.MapGroup("api/v{version:apiVersion}/orders")
.WithApiVersionSet(versionSet)
.MapToApiVersion(new ApiVersion(1, 0));
var v2 = app.MapGroup("api/v{version:apiVersion}/orders")
.WithApiVersionSet(versionSet)
.MapToApiVersion(new ApiVersion(2, 0));
v1.MapGet("/", OrderEndpointsV1.GetAll);
v2.MapGet("/", OrderEndpointsV2.GetAll);
[ApiVersion("1.0", Deprecated = true)]
[ApiVersion("2.0")]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
public class OrdersController : ControllerBase
{
[HttpGet, MapToApiVersion("1.0")]
public IActionResult GetV1() { /* ... */ }
[HttpGet, MapToApiVersion("2.0")]
public IActionResult GetV2() { /* ... */ }
}
api-deprecated-versions: 1.0).Sunset header with removal date: Sunset: Sat, 01 Nov 2026 00:00:00 GMT.| Change Type | Version Bump? | Examples | |---|---|---| | Breaking (new version) | Yes | Removed field, renamed field, changed type, changed behavior | | Additive (same version) | No | New optional field, new endpoint, new optional parameter |
api-supported-versions response header.tools
Use when cross-cutting concerns (logging, metrics, validation, authorization) are tangled into command handlers or service methods, when building database command pipelines with reorderable concerns, or when HTTP client pipelines or message handlers need composable, independently-replaceable processing stages. Covers ICommandInterceptor interface, InterceptorPipeline with reverse-chain construction, zero-cost Empty sentinel to skip overhead when no interceptors are registered, and ConfigureAwait(false) discipline for library code. Domain: Architecture, Cross-Cutting Concerns. Level: Intermediate. Tags: interceptor, pipeline, middleware, decorator, cross-cutting-concerns.
development
Use when writing integration tests for Razor Pages, MVC, or Minimal API applications to validate routing, middleware, page rendering, and HTTP behavior without a browser or live server, or when adding fast smoke tests to a CI pipeline. Covers WebApplicationFactory<Program> setup with public partial class Program, in-memory test server, AngleSharp HTML parsing, CSS selector assertions, redirect and status code testing, and a shared static fixture pattern for minimal per-test startup overhead. Domain: Testing, ASP.NET Core. Level: Intermediate. Tags: integration-testing, webapplicationfactory, razor-pages, anglesharp, http-testing.
development
Use when designing indexes for new tables, diagnosing slow queries that are not using indexes efficiently, reviewing index fragmentation and maintenance, or when the current indexing strategy results in key lookups, table scans, or missing index warnings. Covers clustered index key selection (narrow, unique, ever-increasing), non-clustered index design for query patterns, covering indexes with INCLUDE columns, filtered indexes for subset queries, composite index column ordering, DMV-based monitoring for missing and unused indexes, and rebuild vs reorganize maintenance thresholds. Domain: Database, Performance. Level: Intermediate. Tags: index, sql-server, covering-index, filtered-index, performance, dmv, maintenance.
development
Use when building a searchable in-memory catalog or registry for documentation sites, admin panels, or type/API browsers where you need keyword matching, fuzzy search, and ranked results without an external search engine or database. Covers RegistryService with weighted scoring across name, description, keywords, and method names; Levenshtein fuzzy matching; synonym expansion; category and subcategory filtering; and singleton DI registration for datasets of hundreds to low thousands of items. Domain: Search, Data Access Patterns. Level: Intermediate. Tags: search, registry, fuzzy-matching, in-memory, catalog, filtering.