Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

evolving-apis-and-schemas

БесплатноБез исполняемых скриптовНе проверен

Use when changing anything other systems or stored data already depend on — editing a .proto file, writing a database migration, adding or dropping a column…

osmonteroот osmontero★ 18 звёзд на GitHub

Об этом скилле

Evolving APIs and Schemas

Overview

A schema change is a distributed-systems problem wearing a one-line diff. The code that reads your data is not only the code you are about to deploy — it is also the version still running during the rollout, the client you do not control, and the rows written by last year's binary.

Core principle: Old readers and new readers must both be correct at every instant of the rollout. If there is a moment when that is false, the change needs more steps, not more confidence.

Companion skills: writing-plans for sequencing multi-release changes, verifying-before-completion before running anything destructive.

The Iron Law

ADDITIVE FIRST, DESTRUCTIVE LAST — NEVER IN THE SAME DEPLOY

Adding is reversible. Dropping, renaming, and narrowing are not. Between them must sit at least one fully deployed release where both shapes work, plus enough time to be sure you will not roll back across it.

No exceptions:

  • Not for "the old column is definitely unused" — prove it with a query, not a grep
  • Not for "we deploy everything together" — rollouts are not atomic, and rollbacks are not either
  • Not for "it's a tiny table"
  • Not for renames. A rename is a drop and an add, and it is the single most common way to take an outage

Step 1: Identify Your Consumers

Before classifying the change, list who reads this shape. The answer determines whether expand/contract is optional or mandatory.

Consumer Can you redeploy it atomically with the producer? Consequence
Same binary, same struct Yes Ordinary refactor — compiler catches it
Another service you own No — rolling deploys mean both versions run at once Expand/contract required
A client you do not control (SDK, mobile app, third party) No, ever Version it; the old shape is permanent
Persisted data No — you cannot redeploy a row Old-format rows outlive every deploy
A queue or event log No — in-flight messages were written by the old code Both formats must parse
A replica or a peer in a cluster No — mixed versions during upgrade Both directions must interoperate

The row most often forgotten is persisted data. Every value already on disk was written by code you no longer run. If the new code cannot read it, you have shipped a corruption bug that only appears on old records.

Step 2: Classify the Change

Class Examples Requires
Safe Add an optional field; add a new endpoint, table, or RPC; add an index; widen a type Ship it
Expand/contract Add a required field; rename; change a type; split or merge; drop anything The three-phase sequence below
Breaking — must version Change the meaning of an existing name; remove from a published API; narrow accepted input A new version, plus a deprecation window

The distinction between rows two and three: expand/contract works when you can eventually update every reader. When you cannot — a shipped mobile app, a public API — the old shape must keep working for as long as the support window says it will.

Step 3: The Expand/Contract Sequence

Three deploys, in order. Each is independently releasable and independently revertible.

1. EXPAND    Add the new shape. Nothing reads it yet.
             Writers write BOTH old and new.        ← revertible
             ─── deploy, verify, let it soak ───
2. MIGRATE   Backfill existing data into the new shape.
             Switch readers to the new shape.
             Writers still write both.              ← revertible
             ─── deploy, verify, let it soak ───
3. CONTRACT  Stop writing the old shape. Drop it.   ← the point of no return

Gates between phases, not just time: before contracting, confirm with a query that nothing writes the old shape and nothing reads it — application logs, pg_stat_statements, or an explicit counter you added in phase 1. "It has been two weeks" is not evidence.

Backfill is not a migration. Schema changes (DDL) go in the migration; moving data (DML) goes in a separate, resumable, batched job. A single UPDATE over ten million rows holds locks, blows out the WAL, and cannot be resumed after it times out.

Worked recipes for the common cases — add a NOT NULL column, rename, change a type, split a table, SQLite's rebuild procedure: references/migration-recipes.md.

Protobuf and gRPC

The field number is the wire identity. The name is not.

Change Verdict
Add a field with a new number Safe
Add an RPC, message, or enum value Safe for readers that tolerate unknowns
Delete a field Safe only with reserved on both number and name
Reuse a deleted field number Never. Old data decodes into the wrong field, silently
Rename a field Wire-safe; breaks JSON/text encoding and every generated client
Change a field's type Only within a compatible
Полный SKILL.md на GitHub

Установить evolving-apis-and-schemas в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/migration-recipes.md

FAQ

Что делает скилл evolving-apis-and-schemas?

Use when changing anything other systems or stored data already depend on — editing a .proto file, writing a database migration, adding or dropping a column, renaming a field, changing a response shape, changing an enum, or altering a queue message format. Triggers include "will this break clients", "is this backward compatible", "buf breaking", "ALTER TABLE", "migration", "deprecate this endpoint", and any change to a published API version.

Как установить скилл evolving-apis-and-schemas?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл evolving-apis-and-schemas запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить evolving-apis-and-schemas с