agentleFS
Vimalk0703Vimalk0703/shipworthy/skills/architecture/api-versioning/SKILL.md

api-versioning

Skill6 starsChanged 8 months agoMITView on GitHub

Breaking change detection, versioning strategies (URL path vs header), deprecation policies, backward compatibility rules, and OpenAPI spec maintenance.

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Start with URL path versioning.

    line 45
  2. Distinctive:

    Never change the type of an existing field.

    line 63
  3. Distinctive:

    Never remove a field without a deprecation period.

    line 64
  4. Distinctive:

    Every API PR must include spec updates if the contract changes.

    line 87

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Versioning

Breaking Change Detection

A change is breaking if any existing consumer's code would fail after the change:

ChangeBreaking?Action Required
Remove/rename a response fieldYesMajor version bump
Change a field's typeYesMajor version bump
Make optional field requiredYesMajor version bump
Change error codes/shapesYesMajor version bump
Add optional field (request or response)NoSafe
Add new endpointNoSafe

Automated Detection

# CI check: compare OpenAPI spec against last release
oasdiff breaking base-spec.yaml current-spec.yaml --fail-on ERR

Versioning Strategies

URL Path (recommended for public APIs):

GET /v1/users/123
GET /v2/users/123

Explicit, easy to route, easy to understand. Commit to never breaking within a version.

Header Versioning (Stripe-style):

GET /users/123
API-Version: 2025-06-01

Clean URLs, version pinned per API key. Requires version transformation layer.

Start with URL path versioning. Move to header versioning only if you need per-consumer version pinning.

Backward Compatibility Rules

Additions are safe. Removals need a major version.

// Safe: add new field (existing consumers ignore it)
{ "id": "usr_123", "name": "Alice", "avatar_url": "https://..." }

// BREAKING: rename a field -- must be v2
{ "id": "usr_123", "display_name": "Alice" }

// Safe migration: add new field, keep old, deprecate old
{ "id": "usr_123", "name": "Alice", "display_name": "Alice" }
  1. New fields must have defaults that preserve existing behavior.
  2. Never change the type of an existing field.
  3. Never remove a field without a deprecation period.

Deprecation Policy

API TypeMinimum Notice
Public12 months
Partner6 months
Internal3 months

Process: Announce (add Sunset header) -> Document in spec -> Track consumer usage -> Notify remaining consumers 30 days before sunset -> Return 410 Gone after sunset date.

/v1/users/{id}/legacy-profile:
  get:
    deprecated: true
    x-sunset-date: "2026-09-01"
    description: "DEPRECATED: Use /v2/users/{id}/profile. Removal: 2026-09-01."

OpenAPI Spec Maintenance

  • The OpenAPI spec is the source of truth. If spec and code disagree, fix the code.
  • Every API PR must include spec updates if the contract changes.
  • Generate client SDKs from the spec, not by hand.
  • Validate responses against the spec in integration tests.

API Change Review Checklist

  • Is the change additive-only? If not, is there a version bump?
  • Are new fields optional with documented defaults?
  • Is the OpenAPI spec updated?
  • Is a breaking change going through the deprecation process?
  • Are deprecated endpoints returning Sunset headers?

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.