bug-reproduce
Turn a known bug into a tight, red-capable reproducer, then prove the reproducer locks that…
Compute the remote DB migration + Nacos config diff before a test release — apc release db-config-sync really spawns sync-test-migrations.ts --dry-run (never a stub) and diffs Nacos key dumps, stopping at the write boundary. green(0) no diff · staged(3) pending
$ npx -y skills add Prismer-AI/PrismerCloud --skill release-db-config-sync --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/release-db-config-syncContext preview
The summary Claude sees to decide when to auto-load this skill.
Compute the remote DB migration + Nacos config diff before a test release — apc release db-config-sync really spawns sync-test-migrations.ts --dry-run (never a stub) and diffs Nacos key dumps, stopping at the write boundary. green(0) no diff · staged(3) pending
name: release-db-config-sync description: Compute the remote DB migration + Nacos config diff before a test release — apc release db-config-sync really spawns sync-test-migrations.ts --dry-run (never a stub) and diffs Nacos key dumps, stopping at the write boundary. green(0) no diff · staged(3) pending migrations/missing keys await approval · blocked(1) real script failed. Diff only, never writes the remote. license: MIT scope: coding compatibility: - claude-code allowed-tools: - Bash metadata: category: release
发版前算清**远端 DB 迁移**与 **Nacos 配置**的差异(`apc/01` §2 db-config-sync,收口步 3/4)。这是治 **R3**("DB sync 走桩、`writes:0` 换马甲冒充已同步")的真机制:它**真 spawn** `scripts/ops/sync-test-migrations.ts --dry-run`——真解析凭证、真连库、真算迁移计划——退出码由真脚本决定,**绝不注入桩**。Nacos 侧对两份 key dump 算真差集。**dry-run 永不写库、不写真 Nacos**——止于写入边界,真 apply 走审批后的远端路径。
**什么时候用**:`release-preflight` 绿之后、`release-tag` 之前,确认远端 test 环境的迁移账本和配置 key 都对齐了才发版。
> `apc` **不在 PATH**——在仓库根用 `npx tsx sdk/apc/bin/apc.ts <sub>`。
| 命令 | 作用 | 退出码 | | --- | --- | --- | | `npx tsx sdk/apc/bin/apc.ts release db-config-sync [--ref <dump>] [--cur <dump>] [--json]` | 真跑 `sync-test-migrations.ts --dry-run`(本机替身指向本地 replica,永不写远端)+ 对两份 Nacos dump 算 key 差集 | `0` green(无差异)· `3` staged(有 pending / 缺 key)· `1` blocked(真脚本失败 / 缺凭证) |
`--json` 字段(**名以此为准**):
# 只算迁移(不给 dump 时 key-diff 诚实 skipped): npx tsx sdk/apc/bin/apc.ts release db-config-sync --json > /tmp/dbsync.json; D=$? echo "db-config-sync exit=$D"
要一并算 Nacos key-diff,先用 `dump-nacos-namespace.ts` 产出两份 dump(基准 / 目标现状),再传 `--ref`/`--cur`:
npx tsx sdk/apc/bin/apc.ts release db-config-sync --ref /tmp/nacos-ref.env --cur /tmp/nacos-cur.env --json
| decision | exit | 含义 | 你要做的 | | --- | --- | --- | --- | | `green` | `0` | 无 pending 迁移 + key 无缺失 | 放行 | | `staged` | `3` | 有 pending 迁移 / 目标环境缺 key | 列出 `migration.pending` + `keyDiff.missing`;**审批后**走远端 apply(`sync-test-migrations.ts` 去 `--dry-run` / Nacos 补 key),不得抢跑 | | `blocked` | `1` | 真脚本 exit 非 0(连库失败 / 缺 `REMOTE_MYSQL_*`) | 读 `migration.stderr`,修凭证/连通性——这是前置,别绕开账本自己灌库 |
本 skill 的判据**不是**「报告里出现了 `pending` / `nacos` 这些字」,而是:**重解析你贴的两份 `--json` 产物**、**从 `decision` 反推退出码**、并把 `migration.pending[]` 里的**每一个文件名逐个 stat 回 `src/im/sql/`**(`structured-criteria.ts` 的 `json-claim`)。
本 sample task 钉的是**两次真跑**:一次接通本地 replica(站位远端 test RDS),一次**抽掉 `REMOTE_MYSQL_*` 的负控**——负控是这条用例自带的、必须变红的注入点。
# 1) 连通跑(本地 replica 站位远端 test RDS) REMOTE_MYSQL_HOST=127.0.0.1 REMOTE_MYSQL_PORT=3307 REMOTE_MYSQL_USER=… REMOTE_MYSQL_PASSWORD=… \ REMOTE_MYSQL_DATABASE=prismer_cloud npx tsx sdk/apc/bin/apc.ts release db-config-sync --json # 2) 负控:不带 REMOTE_MYSQL_*,真脚本 throw npx tsx sdk/apc/bin/apc.ts release db-config-sync --json
报告必须带这组行 + **两份原样 JSON**:
MIGRATION-EXIT: 0 KEYDIFF: <keyDiff.status —— skipped | computed> RUN-EXIT: <decision green→0 | staged→3 | blocked→1> NEG-MIGRATION-EXIT: 1 NEG-DECISION: blocked NEG-RUN-EXIT: 1
判据会判红的情况(任一):
**诚实边界**:①判据**证明不了** `pending[]` 的语义正确(哪些真该 apply),只证明每个名字是磁盘上真存在的迁移文件 + 计数自洽。②「未写远端 DB / 真 Nacos」这一条**没有结构化事实可断**(dry-run 的本质就是没有副作用),因此仍保留为**关键词判据**——它是本 skill 唯一还靠措辞的判据,写清楚这点比假装它有牙重要。③接不通 replica 时本 sample task 无法演示,此时判据红是**如实结论**(不是 SUT 红,是本机环境没给到前置)。
1. **decision + 真退出码**:`green`/`staged`/`blocked` ⇄ `0`/`3`/`1`(读回核对)。 2. **迁移计划**:`migration.exitCode` + `pending[]`(列真 sql 文件名,非"若干条")。 3. **key-diff**:`computed` 时给 `missing`/`extra` 计数;`skipped` 时**原样报 skipped + reason**。 4. **是否停在 dry-run 边界**:明确本 skill **没有**写远端库 / 没有写真 Nacos。
**不许**:把桩 / `skipped` 当已验;有 pending 迁移还发版;绕过账本用裸 SQL / Navicat 灌远端。
本 skill 收口 doc03 §1 审批点 **「远端 DB/配置写」**(触发:db-config-sync 应用前)。dry-run 停在写入边界,**真 apply 前必须建人审批并停手**:
1. **出示 dry-run 证据**(审批人看到的,非 agent 自述):迁移 dry-run 计划(
Repo: Prismer-AI/PrismerCloud
Turn a known bug into a tight, red-capable reproducer, then prove the reproducer locks that…
Review a diff against its acceptance criteria in four segments (convention adherence, bug…
Five-dimension design audit (frontend UI/UX · server data-model & flow · endpoint spec ·…
Before merge, mechanize Documentation-First — derive the code delta from git diff, then…
Diagnose the local dev machine before any APC loop step — run apc env doctor, classify each…
Close out a local coding task on the bound daemon — stage, commit, branch, merge, push via…