| name | versioning-apis |
| description | Implement API versioning with backward compatibility, deprecation notices, and migration paths.
Use when managing API versions and backward compatibility.
Trigger with phrases like "version the API", "manage API versions", or "handle API versioning".
|
| allowed-tools | Read, Write, Edit, Grep, Glob, Bash(api:version-*) |
| version | 1.26.0 |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| license | MIT |
| tags | ["api","migration","versioning-apis"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Versioning APIs
Overview
Implement API versioning strategies -- URL path (/v1/, /v2/), header-based (Accept: application/vnd.api.v2+json), or query parameter (?version=2) -- with backward compatibility layers, deprecation notices, and automated migration paths. Manage concurrent version support, sunset timelines, and breaking change detection across the API surface.
Prerequisites
- Existing API codebase with route definitions and controller implementations
- Version control history for tracking breaking changes across releases
- OpenAPI specs for each supported API version (or ability to generate them)
- API gateway or reverse proxy capable of version-based routing (optional: Kong, AWS API Gateway)
- Consumer notification channel for deprecation announcements (changelog, email, response headers)
Instructions
- Audit existing endpoints using Grep and Read to identify current versioning approach (if any) and catalog all public-facing endpoints with their request/response contracts.
- Select a versioning strategy based on API consumer patterns: URL path versioning for public APIs, header versioning for APIs needing clean URLs, or content negotiation for advanced use cases.
- Create a version router that directs requests to the appropriate version handler set based on the extracted version identifier from URL, header, or query parameter.
- Implement version-specific controller directories (
/v1/controllers/, /v2/controllers/) with shared business logic extracted into version-independent service layers.
- Build a compatibility layer that transforms v1 requests into v2 format and v2 responses back to v1 format, enabling older versions to run on the latest business logic.
- Add deprecation headers to sunset versions:
Deprecation: true, Sunset: <date>, and Link: <migration-guide-url>; rel="sunset" per the Sunset HTTP header RFC.
- Create a breaking change detector that compares OpenAPI specs between versions and flags removed fields, changed types, new required parameters, and altered response structures.
- Write version compatibility tests that send v1-formatted requests and verify correct responses, ensuring the compatibility layer preserves backward compatibility.
See ${CLAUDE_SKILL_DIR}/references/implementation.md for the full implementation guide.
Output
${CLAUDE_SKILL_DIR}/src/routes/v1/ - Version 1 route definitions
- - Version 2 route definitions