@skilldeck/migrate 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "migrate",
3
+ "version": "0.1.0",
4
+ "description": "Guardrailed workflows for risky changes: zero-downtime database migrations with a DDL lock linter, dependency and framework upgrades with a lockfile report, and API contract diffs that flag breaking changes. Zero-dependency Node.js.",
5
+ "author": {
6
+ "name": "SkillDeck"
7
+ },
8
+ "license": "MIT",
9
+ "keywords": [
10
+ "migrations",
11
+ "database",
12
+ "postgres",
13
+ "dependency-upgrade",
14
+ "openapi",
15
+ "graphql",
16
+ "breaking-changes"
17
+ ]
18
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kitasid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # migrate
2
+
3
+ **Change the schema, the dependencies or the API without breaking prod.**
4
+
5
+ Outages cluster around three kinds of change:
6
+ - a migration that locks a hot table;
7
+ - an upgrade applied from memory instead of the changelog;
8
+ - an API edit that breaks clients nobody could see.
9
+
10
+ Each skill here pairs a short, opinionated playbook with a zero-dependency checker the agent runs before anything ships. That way "is this safe?" is answered by a tool, not a guess.
11
+
12
+ | Skill | Use when | Checker |
13
+ |---|---|---|
14
+ | `schema-migration` | Writing or reviewing a DB migration: columns, indexes, constraints, type changes, backfills | `lint-ddl.mjs`: flags DDL that blocks writes, rewrites tables or breaks running code (Postgres, MySQL) |
15
+ | `dependency-upgrade` | Bumping a library, framework or toolchain; applying a codemod; lockfile breakage | `upgrade-report.mjs`: classifies what's outdated, audits the lockfile diff, lists every import of a package |
16
+ | `api-contract-diff` | Changing a REST/OpenAPI, GraphQL or protobuf contract | `contract-diff.mjs`: sorts changes into breaking, warning and safe (uses oasdiff, graphql-inspector or buf when installed) |
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npx @skilldeck/migrate install # Claude Code, user-wide
22
+ npx @skilldeck/migrate install --project # this repo only
23
+ npx @skilldeck/migrate install --agent all # also Codex and .agents
24
+ # or, with every SkillDeck pack available:
25
+ npx @skilldeck/cli add migrate
26
+ ```
27
+
28
+ Claude Code marketplace: `/plugin marketplace add kitasid/skilldeck`, then `/plugin install migrate@skilldeck`.
29
+
30
+ ## Run the checkers yourself
31
+
32
+ They work without an agent, in CI, or in a pre-merge hook:
33
+
34
+ ```bash
35
+ npx @skilldeck/migrate lint prisma/migrations # exit 1 on lock-heavy DDL
36
+ alembic upgrade head --sql | npx @skilldeck/migrate lint -
37
+ npx @skilldeck/migrate upgrade outdated # upgrade steps, majors last
38
+ npx @skilldeck/migrate upgrade usages react # every import and the names used
39
+ npx @skilldeck/migrate contract openapi.yaml --base origin/main # exit 1 on breaking changes
40
+ ```
41
+
42
+ ## What `lint-ddl` catches
43
+
44
+ On Postgres:
45
+ - `CREATE INDEX` without `CONCURRENTLY`
46
+ - `ADD COLUMN ... NOT NULL` without a default
47
+ - volatile or stored-generated defaults that rewrite the table
48
+ - `ALTER COLUMN TYPE`
49
+ - `SET NOT NULL` without a validated check
50
+ - foreign-key and check constraints added without `NOT VALID`
51
+ - unique or primary-key constraints added without a prebuilt index
52
+ - `VACUUM FULL` and `CLUSTER`
53
+ - migrations that set no `lock_timeout`
54
+
55
+ On MySQL, it catches `MODIFY`/`CHANGE COLUMN` and index builds without `ALGORITHM` or `LOCK` guards.
56
+
57
+ On both, it flags:
58
+ - renames
59
+ - drops
60
+ - data changes inside the migration
61
+
62
+ Tables created in the same file are exempt, since locking an empty table costs nothing. Every finding comes with the safe recipe (see `skills/schema-migration/references/postgres-locks.md`).
63
+
64
+ MIT licensed. Node 20+. No dependencies beyond `@skilldeck/core` for the installer.
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process'
3
+ import { runPackCli } from '@skilldeck/core'
4
+ import pack, { scripts } from '../index.mjs'
5
+
6
+ // Checkers run the exact scripts the skills ship, so CLI and agent behave identically.
7
+ function run(script, args) {
8
+ const r = spawnSync(process.execPath, [script, ...args], { stdio: 'inherit' })
9
+ process.exitCode = r.status ?? 1
10
+ }
11
+
12
+ await runPackCli(pack, process.argv.slice(2), {
13
+ extraCommands: {
14
+ lint: (args) => run(scripts.lint, args),
15
+ upgrade: (args) => run(scripts.upgrade, args),
16
+ contract: (args) => run(scripts.contract, args),
17
+ },
18
+ extraHelp: `
19
+ Checkers (no agent needed):
20
+ migrate-skills lint <file|dir...> [--dialect postgres|mysql] flag lock-heavy or app-breaking DDL
21
+ migrate-skills upgrade outdated|diff|usages ... plan and audit dependency upgrades
22
+ migrate-skills contract <old> <new> breaking changes between two API specs
23
+ `,
24
+ })
package/index.mjs ADDED
@@ -0,0 +1,21 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ const root = path.dirname(fileURLToPath(import.meta.url))
6
+ const { version } = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
7
+
8
+ /** Pack descriptor consumed by @skilldeck/core. */
9
+ export default {
10
+ name: 'migrate',
11
+ version,
12
+ root,
13
+ description: 'Change things without breaking prod: schema migrations, dependency upgrades, API contracts.',
14
+ skills: ['schema-migration', 'dependency-upgrade', 'api-contract-diff'],
15
+ }
16
+
17
+ export const scripts = {
18
+ lint: path.join(root, 'skills', 'schema-migration', 'scripts', 'lint-ddl.mjs'),
19
+ upgrade: path.join(root, 'skills', 'dependency-upgrade', 'scripts', 'upgrade-report.mjs'),
20
+ contract: path.join(root, 'skills', 'api-contract-diff', 'scripts', 'contract-diff.mjs'),
21
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@skilldeck/migrate",
3
+ "version": "0.1.0",
4
+ "description": "Change things without breaking prod: zero-downtime schema migrations, dependency upgrades and API contract diffs, each backed by a zero-dependency checker script.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./index.mjs"
8
+ },
9
+ "main": "./index.mjs",
10
+ "bin": {
11
+ "migrate-skills": "bin/migrate.mjs"
12
+ },
13
+ "files": [
14
+ "index.mjs",
15
+ "bin/",
16
+ "skills/",
17
+ ".claude-plugin/",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "dependencies": {
22
+ "@skilldeck/core": "^0.1.0"
23
+ },
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "license": "MIT",
28
+ "keywords": [
29
+ "claude-code",
30
+ "agent-skills",
31
+ "skill-md",
32
+ "migrations",
33
+ "database",
34
+ "dependency-upgrade",
35
+ "openapi",
36
+ "breaking-changes"
37
+ ],
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "author": "kitasid"
42
+ }
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: api-contract-diff
3
+ description: Use when changing a public or cross-service API (REST/OpenAPI, GraphQL schema, protobuf/gRPC), editing request or response shapes, removing or renaming endpoints, fields, arguments or enum values, reviewing a PR that touches an API spec, or deciding whether a change needs a new API version or a deprecation period.
4
+ ---
5
+
6
+ # API Contract Diff
7
+
8
+ A breaking API change is decided by *clients you can't see*. A mobile app from last year, a partner's cron job and another team's service all keep sending yesterday's requests and reading yesterday's responses. Don't judge "is it breaking" by feel. Diff the contract and classify each change.
9
+
10
+ Announce: "Using api-contract-diff to check <API> for breaking changes."
11
+
12
+ **Script location.** `${CLAUDE_SKILL_DIR}/scripts/contract-diff.mjs`. If `CLAUDE_SKILL_DIR` is not set, use the directory containing this SKILL.md. Below, `$S` stands for the scripts folder. It needs Node 20+. It calls `oasdiff`, `graphql-inspector` or `buf` when they are installed, and otherwise uses its built-in checker.
13
+
14
+ ## The Rule
15
+
16
+ ```
17
+ No breaking change ships without a version bump or a deprecation window, and the user deciding which.
18
+ ```
19
+
20
+ ## Checklist
21
+
22
+ Copy this into your reply and tick it off:
23
+
24
+ ```
25
+ - [ ] 1. Found the contract (spec file, schema, .proto) and who consumes it
26
+ - [ ] 2. Contract is updated to match the code change (or generated from it)
27
+ - [ ] 3. contract-diff run against the released version
28
+ - [ ] 4. Every BREAKING item: removed, made additive, or explicitly accepted by the user
29
+ - [ ] 5. Every WARNING item: judged and noted
30
+ - [ ] 6. Deprecations/versioning applied per references/versioning.md
31
+ ```
32
+
33
+ ## 1. Find the contract and its consumers
34
+
35
+ - **The contract:** look for `openapi.{json,yaml}`, `swagger.*`, `schema.graphql`, `*.proto`, or a generator (FastAPI `/openapi.json`, NestJS `SwaggerModule`, `graphql-codegen`, `buf.gen.yaml`).
36
+ - **If there's no spec file:** generate one from the code at both git refs, or stop and tell the user that without a contract this check is only a guess.
37
+ - **Consumers:** decide whether the API is public, partner-facing, used by first-party mobile apps (which can't be updated in lockstep), or internal only. This decides how much breakage is acceptable, and it's the user's call if you can't tell.
38
+
39
+ ## 2. Keep the contract in step with the code
40
+
41
+ If the spec is written by hand, update it in the same change as the code. If it's generated, regenerate it. A diff between two stale specs proves nothing.
42
+
43
+ ## 3. Diff against what is released
44
+
45
+ ```bash
46
+ node $S/contract-diff.mjs openapi.yaml --base origin/main # working tree vs main
47
+ node $S/contract-diff.mjs api/v1.json api/v2.json # two files
48
+ node $S/contract-diff.mjs schema.graphql --base v3.2.0 --json
49
+ ```
50
+
51
+ - Use the version that is actually deployed as the base: the release tag or the production branch, not your branch's previous commit.
52
+ - Exit code 1 means there are breaking changes.
53
+
54
+ What the built-in checker treats as breaking:
55
+ - In a **request** (what the client sends): new required inputs, stricter types or enums, and removed accepted values.
56
+ - In a **response** (what the client reads): removed fields, fields that became optional or nullable, and changed types.
57
+ - Adding enum values to a response is a **warning**, because clients with exhaustive switches may fail on the new value.
58
+ - Protobuf: field numbers removed without `reserved`, and type or label changes.
59
+
60
+ ## 4. Resolve each breaking item
61
+
62
+ For each item, prefer the options in this order:
63
+
64
+ 1. **Make it additive instead.** Add the new field next to the old one; accept both request shapes; keep the old enum value and map it on the server.
65
+ 2. **Deprecate, then remove later.** Mark the old item deprecated in the contract and send runtime signals, then remove it in a later release after a stated window. See `references/versioning.md`.
66
+ 3. **Version it.** Serve both `/v1` and `/v2`, or add a new GraphQL field or gRPC method, and keep the old one working.
67
+ 4. **Break it on purpose.** Only when the user explicitly accepts it for a known set of consumers, and record that decision in the PR.
68
+
69
+ Never resolve an item by editing the base spec, and never mark it safe without a reason.
70
+
71
+ ## 5. Judge warnings
72
+
73
+ Warnings are changes that may break some clients: parameters removed from requests, enum values added to responses, deprecations, protobuf renames (which break JSON and field masks). Write one line per warning in the report.
74
+
75
+ ## Report
76
+
77
+ ```
78
+ Contract: <file> (<format>), base <ref>, consumers <public|partner|mobile|internal>
79
+ Breaking: <n> -> <resolution per item: additive | deprecated until <date> | v2 | accepted by user>
80
+ Warnings: <n> -> <one line each>
81
+ Safe additions: <n>
82
+ ```
83
+
84
+ ## Red flags
85
+
86
+ | Thought | Reality |
87
+ |---|---|
88
+ | "Nobody uses that field." | You can't see every client. Check logs or usage metrics, or deprecate it first. |
89
+ | "It's just a rename." | To a client, a rename is a removal plus an addition. |
90
+ | "Making it required is safer." | It is safer for the server, and it breaks every existing caller that omits it. |
91
+ | "Adding an enum value is additive." | For a request it is. For a response, a client with a strict switch now crashes. |
92
+ | "We'll bump the version later." | Clients break the moment you deploy, not when the version changes. |
@@ -0,0 +1,50 @@
1
+ # Deprecation and versioning playbook
2
+
3
+ ## REST / OpenAPI
4
+
5
+ **Deprecate in the contract.** Set `deprecated: true` on the operation, parameter or schema property, and name the replacement in the `description`.
6
+
7
+ **Signal it at runtime.** Send these headers on every response from the deprecated endpoint:
8
+ - `Deprecation: @1767225600`: the date it became deprecated, as a Unix timestamp. This is the structured-field date form from RFC 9745.
9
+ - `Sunset: Wed, 30 Jun 2027 00:00:00 GMT`: when it will stop working (RFC 8594).
10
+ - `Link: <https://docs.example.com/migrate-v2>; rel="deprecation"`: where to read how to migrate.
11
+
12
+ **Choose the window.** It depends on who consumes the API:
13
+ - Internal services: often one or two release cycles.
14
+ - Public APIs and mobile apps: months. Mobile apps are only safe to break once the oldest supported app version no longer calls the endpoint.
15
+
16
+ Before you remove anything, measure it: log or count calls to the deprecated surface, and remove only when the count is at, or close to, zero.
17
+
18
+ **Versioning styles:**
19
+ - A URL prefix (`/v2/...`) is the easiest to route and cache.
20
+ - A header or media type (`Accept: application/vnd.example.v2+json`) keeps URLs stable.
21
+ - Date-based versions (`Stripe-Version: 2026-09-01`) suit APIs that ship many small changes.
22
+
23
+ Pick the one the API already uses. Don't mix styles.
24
+
25
+ **Tolerant readers.** Make it easier for clients to cope with change: document that clients must ignore unknown response fields, and handle unknown enum values with a fallback.
26
+
27
+ ## GraphQL
28
+
29
+ - Deprecate with `@deprecated(reason: "Use fullName. Removal after 2027-01-01.")` on fields, arguments, input fields and enum values.
30
+ - Evolve the schema instead of versioning it. Add the new field, move clients over, then remove the old field once usage is zero. Field-level usage comes from Apollo GraphOS, from Hive, or from your own resolver logging.
31
+ - New arguments and input fields must be nullable or have a default.
32
+ - Never change the type of an existing field. Add a new field with the new type instead.
33
+
34
+ ## Protobuf / gRPC
35
+
36
+ - Never reuse a field number. When you remove a field, add `reserved 2;` and `reserved "email";` so nobody can bring the number or name back.
37
+ - Changing a field type is safe only between wire-compatible types, such as `int32`, `uint32`, `int64`, `uint64` and `bool`. Even then, values can be truncated. Treat any type change as breaking unless you have checked this.
38
+ - Renaming a field is wire-compatible, but it breaks JSON transcoding and field masks.
39
+ - In proto3, enums must start with an `UNSPECIFIED = 0` value, and clients must handle unknown values.
40
+ - To version, add a new package (`example.users.v2`) and serve the v1 and v2 services side by side.
41
+ - `buf breaking --against '.git#branch=main'` is the standard check in CI.
42
+
43
+ ## What to put in the PR
44
+
45
+ ```
46
+ API change: <summary>
47
+ Breaking items: <list, or "none (contract-diff clean vs <ref>)">
48
+ Plan: additive | deprecated (Sunset <date>) | new version <v> | accepted breakage (approved by <who>)
49
+ Consumers notified: <where / changelog entry>
50
+ ```