‹ 首页

api-versioning-strategy

@aj-geddes · 收录于 5 天前 · 上游提交 4 个月前

Implement API versioning strategies including URL versioning, header versioning, backward compatibility, deprecation strategies, and migration guides. Use when dealing with API versions, deprecating endpoints, or managing breaking changes.

适合你,如果需要在不停服的情况下安全地演进 API 版本。

/ 通过 npx 安装 校验哈希
npx oh-my-skill add aj-geddes/useful-ai-prompts/api-versioning-strategy
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- aj-geddes/useful-ai-prompts/api-versioning-strategy
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify aj-geddes/useful-ai-prompts/api-versioning-strategy
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
300GitHub stars
~757最小装载
~3.7K含声明引用
~3.9K文本包总量
索引托管

怎么用

商店整理自技能原文 · 版本 3f5182c · 表述以原文为准
它做什么

Claude 会帮你设计和实施 API 版本化策略,包括 URL 版本化、头部版本化、向后兼容、弃用策略和迁移指南。

什么时候触发

当你涉及 API 版本管理、弃用端点或处理破坏性变更时触发。

装好后可以这样说
Claude 会给出具体代码示例。
Claude 会介绍兼容模式。
Claude 会制定弃用计划和迁移步骤。
技能原文 SKILL.md作者撰写 · MIT · 3f5182c

API Versioning Strategy

Table of Contents
  • [Overview](#overview)
  • [When to Use](#when-to-use)
  • [Quick Start](#quick-start)
  • [Reference Guides](#reference-guides)
  • [Best Practices](#best-practices)
Overview

Comprehensive guide to API versioning approaches, deprecation strategies, backward compatibility techniques, and migration planning for REST APIs, GraphQL, and gRPC services.

When to Use
  • Designing new APIs with versioning from the start
  • Adding breaking changes to existing APIs
  • Deprecating old API versions
  • Planning API migrations
  • Ensuring backward compatibility
  • Managing multiple API versions simultaneously
  • Creating API documentation for different versions
  • Implementing API version routing
Quick Start

Minimal working example:

// express-router.ts
import express from "express";

const app = express();

// Version 1
app.get("/api/v1/users", (req, res) => {
  res.json({
    users: [{ id: 1, name: "John Doe" }],
  });
});

// Version 2 - Added email field
app.get("/api/v2/users", (req, res) => {
  res.json({
    users: [{ id: 1, name: "John Doe", email: "john@example.com" }],
  });
});

// Shared logic with version-specific transformations
app.get("/api/:version/users/:id", async (req, res) => {
  const user = await userService.findById(req.params.id);

  if (req.params.version === "v1") {
    res.json({ id: user.id, name: user.name });
// ... (see reference guides for full implementation)
Reference Guides

Detailed implementations in the references/ directory:

| Guide | Contents | |---|---| | [Versioning Approaches](references/versioning-approaches.md) | Versioning Approaches | | [Backward Compatibility Patterns](references/backward-compatibility-patterns.md) | Backward Compatibility Patterns | | [Deprecation Strategy](references/deprecation-strategy.md) | Deprecation Strategy | | [Migration Guide Example](references/migration-guide-example.md) | Migration Guide Example | | [Response Structure](references/response-structure.md) | Response Structure | | [Date Format](references/date-format.md) | Date Format, Error Format | | [JavaScript/TypeScript](references/javascripttypescript.md) | JavaScript/TypeScript, Python | | [GraphQL Versioning](references/graphql-versioning.md) | GraphQL Versioning | | [gRPC Versioning](references/grpc-versioning.md) | gRPC Versioning | | [Version Detection & Routing](references/version-detection-routing.md) | Version Detection & Routing | | [Testing Multiple Versions](references/testing-multiple-versions.md) | Testing Multiple Versions | | [Pattern 1: Version-Agnostic Core](references/pattern-1-version-agnostic-core.md) | Pattern 1: Version-Agnostic Core, Pattern 2: Feature Flags for Gradual Rollout, Pattern 3: API Version Metrics |

Best Practices
✅ DO
  • Version from day one (even if v1)
  • Document breaking vs non-breaking changes
  • Provide clear migration guides with code examples
  • Use semantic versioning principles
  • Give 6-12 months deprecation notice
  • Monitor usage of deprecated APIs
  • Send deprecation warnings to API consumers
  • Support at least 2 versions simultaneously
  • Use adapters/transformers for version logic
  • Test all supported versions
  • Log which API version is being used
  • Provide migration tooling when possible
  • Be consistent with versioning approach
❌ DON'T
  • Change API behavior without versioning
  • Remove versions without notice
  • Support too many versions (>3)
  • Use different versioning strategies in same API
  • Break APIs without incrementing version
  • Forget to update documentation
  • Deprecate too quickly (<6 months)
  • Ignore feedback from API consumers
  • Make every change a new version
  • Use version numbers inconsistently
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。