本文へ移動
cccskills
無料GitHub で公開

api-versioning

Manage API versioning and evolution with URL/header/query strategies, deprecation workflows, breaking change classification, sunset headers, and consumer-driven contract testing. Use when designing versioning strategy, deprecating endpoints, or evolving API contracts.

インストール方法を見る

含まれるファイル(2)

  • SKILL.md6.4 KB
  • references/typescript.md4.3 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

API Versioning & Evolution

APIs are contracts with consumers. Breaking that contract destroys trust. This skill covers how to version, evolve, and deprecate APIs without breaking clients.

Stack-Specific References

After reading the methodology below, read the reference matching your surface's framework:

FrameworkReference
TypeScript / Node.jsreferences/typescript.md

Versioning Strategies

StrategyExampleProsCons
URL path/api/v2/modelsObvious, cacheable, easy routingURL represents resource not version; copies endpoints
HeaderAPI-Version: 2Clean URLs, content negotiationHidden from browser, harder to test
Query param/api/models?version=2Easy to test, no routing changesPollutes query string, cache key complexity
Accept headerAccept: application/vnd.api.v2+jsonProper content negotiationVerbose, often misunderstood

Recommendation

Use URL path versioning for public APIs (simplicity and discoverability). Use header versioning for internal/partner APIs (cleaner resource model).


Default Version Behavior

StrategyBehaviorWhen to Use
Default to latestUnversioned requests get the newest versionInternal APIs with controlled consumers
Default to oldest supportedUnversioned requests get V1Public APIs (avoid surprise breakage)
Require explicit versionReturn 400 if no version specifiedStrict APIs where ambiguity is unacceptable

Breaking vs Non-Breaking Changes

Non-Breaking (Safe to Ship)

ChangeExampleWhy It Is Safe
Add optional field to response"avatar_url": "..." addedClients ignore unknown fields
Add optional query parameter?sort=name now supportedExisting queries still work
Add new endpointPOST /api/v1/webhooksDoes not affect existing endpoints
Widen accepted input typesField accepts `stringnumber`
Add optional request field"metadata": {} now acceptedExisting requests without it still work
Relax validationMax length 100 → 200Previously valid inputs still valid

Breaking (Requires New Version)

ChangeExampleWhy It Breaks
Remove field from responseprice_per_token removedClients reading this field break
Rename fieldprice_per_token → pricingClients reading old name break
Change field typeprice from number to objectParsing breaks
Remove endpointDELETE /api/v1/legacyClients calling it get 404
Add required request field"region" now requiredExisting requests missing it fail
Tighten validationMax length 200 → 100Previously valid inputs rejected
Change error response formatDifferent error shapeClient error handling breaks
Change authentication schemeBearer token → API keyAuth headers break

Additive-Only API Policy

The safest evolution strategy: never remove or rename, only add.

V1 response:
  { id, name, price_per_token }

V1.1 response (additive — no new version needed):
  { id, name, price_per_token, pricing: { input, output, currency, unit } }

Clients reading price_per_token still work.
New clients use pricing object.
Remove price_per_token only in V2.

Sunset Headers and Deprecation Workflow

Sunset Header (RFC 8594)

Every deprecated endpoint/version must include these headers:

  • Deprecation: true
  • Sunset: <HTTP date> — when this version will stop working
  • Link: <migration-url>; rel="sunset"

Deprecation Timeline

PhaseDurationActions
AnnounceT-6 monthsAdd Deprecation: true header, publish migration guide
WarnT-3 monthsAdd Sunset header with date, email consumers
MonitorT-1 monthTrack usage, notify active consumers directly
SunsetT-0Return 410 Gone with migration link
RemoveT+3 monthsRemove code (keep tests to prevent regression)

Consumer-Driven Contract Testing

Consumers define the contract they depend on. The provider runs these contracts in CI.

Concept:

  1. Each API consumer writes contract tests specifying fields they depend on
  2. Provider runs ALL consumer contracts in CI before deploy
  3. If a consumer contract breaks, the deploy is blocked
  4. Adding new fields never breaks contracts (consumers ignore unknown fields)

Changelog Automation

Conventional Commits for API Changes

feat(api): add /api/v1/webhooks endpoint
fix(api): correct pagination cursor encoding in /api/v1/models
deprecate(api): mark /api/v1/legacy/search as deprecated
breaking(api): remove price_per_token field from /api/v2/models response

Migration Guides

Every version bump must include a migration guide:

  1. Timeline — deprecation date, sunset date, removal date
  2. Breaking changes — before/after for each changed field or endpoint
  3. Migration steps — numbered steps to update client code
  4. Testing instructions — how to verify migration works

Anti-Patterns

Anti-PatternCorrect Approach
Increment version for every changeVersion only on breaking changes
Remove old version without noticeFollow deprecation timeline (6+ months)
Different versioning per endpointConsistent strategy across the entire API
Version in the response body onlyUse URL path or headers — visible and consistent
No default version behaviorDefine and document the default
Breaking change without migration guideEvery breaking change needs a guide
No consumer notificationEmail, changelog, and headers all used together

References

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Audit and improve web accessibility following WCAG 2.1 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible".

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Structured methodology for adversarial thinking — generating attack scenarios, abuse cases, race conditions, and security edge cases against specs and implementations. Produces spec-level gap items, not code-level fixes.

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Orchestrate multiple Antigravity skills through guided workflows for SaaS MVP delivery, security audits, AI agent builds, and browser QA.

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Analyzes codebase structure, data flow, module relationships, and key patterns to generate and maintain a living architecture document (ARCHITECTURE.md).

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Orchestrate ambiguity auditing across selected layers with rubric-driven scoring, remediation flow, and next-step gating

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

RepairYourTech のスキルをすべて見る

このスキルの問題を報告する