[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M754VVYGPZ9FW5P9YKBW66RH":3,"skill-same:01M754VVYGPZ9FW5P9YKBW66RH":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":32,"repositoryHtmlUrl":33,"repositoryHomepageUrl":6,"ownerHtmlUrl":34,"ownerBlogUrl":35,"ownerDescription":36,"updatedAt":37,"install":38,"resources":50},"01M754VVYGPZ9FW5P9YKBW66RH","x-manage-pr-merge-train",null,"Merge-train automation: discovers, validates, and merges a sequence of PRs into develop in deterministic order. Supports --prs, --epic, and --pattern discovery modes with pre-merge validation and dry-run auditing.","review-bench\u002Federcnj_ia-dev-environment","review-bench","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F286778065?v=4","01M7517F9NTEPDZDAXJBR30FWT","ReviewBench","01M7517FAC9F4P7TGWCNJ8VYVW",0,"MIT","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring-fintech-pci\u002F.claude\u002Fskills\u002Fx-manage-pr-merge-train\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: x-manage-pr-merge-train\ndescription: \"Merge-train automation: discovers, validates, and merges a sequence of PRs into develop in deterministic order. Supports --prs, --epic, and --pattern discovery modes with pre-merge validation and dry-run auditing.\"\nuser-invocable: true\nallowed-tools: Read, Write, Edit, Bash, Grep, Glob, Skill, Agent, TaskCreate, TaskUpdate\nargument-hint: \"[--prs N,M,...] [--epic ID] [--pattern regex] [--max-parallel N] [--dry-run] [--resume]\"\ncontext-budget: medium\nrequires-capabilities: []\n---\n\n## Global Output Policy\n\n- **Language**: English ONLY.\n- **Tone**: Technical, Direct, and Concise.\n- **Efficiency**: Remove all conversational fillers. Start directly with technical information.\n- **Progress lines**: Prefix with the current phase, e.g. `[Phase 0]`, `[Phase 1]`, `[Phase 2]`.\n\n## Triggers\n\n```\n\u002Fx-manage-pr-merge-train --epic 0042 --dry-run\n\u002Fx-manage-pr-merge-train --prs 374,375,376\n\u002Fx-manage-pr-merge-train --pattern \"feat\u002Ftask-0042-\" --max-parallel 2\n\u002Fx-manage-pr-merge-train --epic 0042 --resume\n```\n\n## Parameters\n\n| Flag | Type | Required | Default | Description |\n| :--- | :--- | :--- | :--- | :--- |\n| `--prs` | `String` (CSV integers) | Mutually exclusive¹ | — | Literal comma-separated PR numbers; order preserved. |\n| `--epic` | `String` (4-digit ID) | Mutually exclusive¹ | — | Reads `ai\u002Fepics\u002Fepic-{ID}\u002Fexecution-state.json` to resolve PRs. |\n| `--pattern` | `String` (GitHub search regex) | Mutually exclusive¹ | — | Enumerates open PRs via `gh pr list --search`. Sorted by `createdAt`. |\n| `--max-parallel` | `Integer` | Optional | `3` | Max concurrent rebase workers in Phase 5 (1–8). |\n| `--dry-run` | Flag | Optional | `false` | Report plan and VETOs without merging. Exits after Phase 2. |\n| `--resume` | Flag | Optional | `false` | Resume interrupted train from `plans\u002Fmerge-train\u002F{id}\u002Fstate.json`. |\n\n> ¹ Exactly one of `--prs`, `--epic`, or `--pattern` must be provided; zero or multiple emits `MODE_AMBIGUOUS`.\n\n## Output Contract\n\n| Artifact | Path | Description |\n| :--- | :--- | :--- |\n| `state.json` | `plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json` | Full train lifecycle state; survives interruptions and supports `--resume`. |\n| `report.md` | `plans\u002Fmerge-train\u002F{trainId}\u002Freport.md` | Human-readable completion report: PRs merged, waves, errors, duration. |\n| `worker-{pr}.log` | `plans\u002Fmerge-train\u002F{trainId}\u002Fworker-{pr}.log` | Per-PR rebase worker result: `{status, headSha, durationMs, reason?}`. |\n\nTrain state transitions: `PREPARATION → DISCOVERY → VALIDATION → SORTING → MERGING_BASE → WAVE_N_DISPATCHED → WAVE_N_RETURNED → VERIFYING → REPORTING → COMPLETED` (or `FAILED`).\n\n## Error Envelope\n\n| Code | Phase | Condition | Remediation |\n| :--- | :--- | :--- | :--- |\n| `MODE_AMBIGUOUS` | 1 | 0 or 2+ mode flags | Provide exactly one of `--prs`, `--epic`, `--pattern`. |\n| `EPIC_STATE_MISSING` | 1 | `--epic N` but no `execution-state.json` | Use `--prs` or `--pattern`. |\n| `PR_CLOSED` | 2 | `state != \"OPEN\"` | Remove from train or reopen. |\n| `PR_DRAFT` | 2 | `isDraft == true` | Mark PR as Ready for review. |\n| `PR_BASE_MISMATCH` | 2 | `baseRefName != \"develop\"` | Rebase PR against develop. |\n| `PR_NOT_APPROVED` | 2 | `reviewDecision != \"APPROVED\"` | Request review. |\n| `PR_CI_FAILING` | 2 | CI has `FAILURE`\u002F`ERROR` check | Fix CI. |\n| `PR_MERGE_CONFLICT` | 2 | `mergeable == \"CONFLICTING\"` | Rebase manually. |\n| `NEUTERED_PARALLEL` | 3 | Code-file overlap detected (advisory, non-fatal) | `MAX_PARALLEL=1` forced; train continues serially. |\n| `MERGE_REJECTED_BY_PROTECTION` | 4–5 | Branch protection blocks merge | Adjust protection rules. |\n| `MERGE_POLL_TIMEOUT` | 4–5 | PR did not reach `MERGED` within timeout | Increase `--merge-timeout-seconds` or investigate CI. |\n| `CODE_CONFLICT_NEEDS_HUMAN` | 5 | Rebase conflict in non-golden file | Resolve manually → `git rebase --continue` → push → `--resume`. |\n| `PUSH_LEASE_REJECTED` | 5 | `--force-with-lease` rejected after retry | Fetch + rebase manually → `--resume`. |\n| `GOLDENS_REGEN_FAILED` | 5 | `GoldenFileRegenerator` non-zero | Diagnose build failure; see worker log. |\n| `SMOKE_TEST_FAILED` | 6 | `mvn test` fails after all merges | Diagnose; worktree preserved for diagnosis. |\n| `STATE_CONFLICT` | resume | No `state.json` or ambiguous train ID | Start fresh or provide `--train-id`. |\n\n## Phase Overview (Rule 25 — Task Hierarchy)\n\nEight phases (Rule 25 REGRA-001, EPIC-0055). Each opens with a PRE gate + `TaskCreate`, closes with a POST\u002FFINAL gate + `TaskUpdate(completed)`. Phase 0 is exempted from gates (read-only setup). Full per-phase implementation in `references\u002Ffull-protocol.md`.\n\n```\n0. PREPARATION  → detect state file, parse args, validate mode flag (inline)\n1. DISCOVERY    → enumerate PRs for the chosen mode (inline + gh CLI)\n2. VALIDATION   → VETO check per PR — open, non-draft, approved, CI pass (inline)\n3. SORTING      → topological sort + overlap pre-check (inline)\n4. BASE-MERGE   → merge base wave into develop (x-merge-pr per PR)\n5. REBASE-WAVE  → parallel rebase workers per wave (subagents)\n6. SMOKE-VERIFY → mvn test after all merges (inline)\n7. REPORT       → write report.md + cleanup (inline)\n```\n\nState machine: `PREPARATION → DISCOVERY → VALIDATION → SORTING → MERGING_BASE → WAVE_N_DISPATCHED → WAVE_N_RETURNED → VERIFYING → REPORTING → COMPLETED` (or `FAILED`).\n\n\u003C!-- phase-no-gate: read-only arg parsing and state-file detection; no artifact produced -->\n## Phase 0 - Preparation\n\nOpen a phase tracker (close with `TaskUpdate(id: phase0TaskId, status: \"completed\")` at end of setup):\n\n    TaskCreate(subject: \"PR-MERGE › Phase 0 - Preparation\", activeForm: \"Preparing merge-train setup\")\n\nResolve `--resume` (load existing `state.json`) vs fresh run. Validate exactly one of `--prs`, `--epic`, `--pattern`. Produce `trainId` (derived from mode + epoch). Errors: `MODE_AMBIGUOUS`, `EPIC_STATE_MISSING`, `STATE_CONFLICT`.\n\nSee `references\u002Ffull-protocol.md §Phase 0` for full implementation.\n\nPersist interactiveMode to state file (EPIC-0068 — consumed by Stop hook `enforce-continuous-flow.sh`):\n\n    Skill(skill: \"x-internal-update-status\", args: \"--file plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json --type merge-train --id {trainId} --field interactiveMode --value \u003Cinteractive|non-interactive>\")\n\nValue: `\"interactive\"` when `--interactive` passed or `CLAUDE_LEGACY_INTERACTIVE=1`; otherwise `\"non-interactive\"` (Rule 20 default, EPIC-0061).\n\n    TaskUpdate(id: phase0TaskId, status: \"completed\")\n\n## Phase 1 - Discovery\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-1-Discovery\")\n    TaskCreate(subject: \"PR-MERGE › Phase 1 - Discovery\", activeForm: \"Discovering PRs for merge train\")\n\nEnumerate PRs per chosen mode:\n- `--prs`: parse CSV, preserve order.\n- `--epic`: read `ai\u002Fepics\u002Fepic-{ID}\u002Fexecution-state.json`, collect merged story PR URLs.\n- `--pattern`: `gh pr list --search {pattern} --state open --json number,createdAt | sort by createdAt`.\n\nWrite initial `state.json` at `plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json` with `phase: DISCOVERY` and the discovered PR list. Advance state to `VALIDATION`.\n\nSee `references\u002Ffull-protocol.md §Phase 1` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-1-Discovery --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase1TaskId, status: \"completed\")\n\n## Phase 2 - Validation\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-2-Validation\")\n    TaskCreate(subject: \"PR-MERGE › Phase 2 - Validation\", activeForm: \"Validating PR merge eligibility\")\n\nFor each discovered PR, query `gh pr view {N} --json state,isDraft,baseRefName,reviewDecision,mergeable,statusCheckRollup` and apply VETO rules:\n- `PR_CLOSED`: `state != OPEN`\n- `PR_DRAFT`: `isDraft == true`\n- `PR_BASE_MISMATCH`: `baseRefName != develop`\n- `PR_NOT_APPROVED`: `reviewDecision != APPROVED`\n- `PR_CI_FAILING`: any check with `FAILURE` or `ERROR`\n- `PR_MERGE_CONFLICT`: `mergeable == CONFLICTING`\n\nIf `--dry-run`: print VETO report and exit after Phase 2. Non-vetoed PRs advance to Phase 3.\n\nSee `references\u002Ffull-protocol.md §Phase 2` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-2-Validation --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase2TaskId, status: \"completed\")\n\n## Phase 3 - Sorting\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-3-Sorting\")\n    TaskCreate(subject: \"PR-MERGE › Phase 3 - Sorting\", activeForm: \"Sorting and overlap-checking PRs\")\n\nTopological sort validated PRs by `createdAt` (or explicit `--prs` order). Run file-overlap pre-check against each pair: if code-file overlap detected, emit `NEUTERED_PARALLEL` advisory and force `MAX_PARALLEL=1` (serial). Update `state.json` with sorted order and parallelism decision.\n\nSee `references\u002Ffull-protocol.md §Phase 3` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-3-Sorting --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase3TaskId, status: \"completed\")\n\n## Phase 4 - Base Merge\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-4-BaseMerge\")\n    TaskCreate(subject: \"PR-MERGE › Phase 4 - Base Merge\", activeForm: \"Merging base PRs into develop\")\n\nFor each PR in sorted order, invoke `x-merge-pr`:\n\n    Skill(skill: \"x-merge-pr\", args: \"--pr {N} --strategy squash --target develop\")\n\nOn `MERGE_REJECTED_BY_PROTECTION` or `MERGE_POLL_TIMEOUT`: abort train with state `FAILED`. Record failed PR in `state.json`. See `references\u002Ffull-protocol.md §Phase 4`.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-4-BaseMerge --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase4TaskId, status: \"completed\")\n\n## Phase 5 - Rebase Wave\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-5-RebaseWave\")\n    TaskCreate(subject: \"PR-MERGE › Phase 5 - Rebase Wave\", activeForm: \"Rebasing PR wave onto develop\")\n\nDispatch rebase workers in parallel (up to `--max-parallel` sibling agents per wave). Each worker:\n1. Creates worktree via `x-manage-worktrees`.\n2. Rebases branch onto develop HEAD.\n3. On `GOLDENS_REGEN_FAILED`: runs `GoldenFileRegenerator` and re-pushes.\n4. On `CODE_CONFLICT_NEEDS_HUMAN`: preserves worktree, marks PR `FAILED`, continues.\n5. Writes result to `plans\u002Fmerge-train\u002F{trainId}\u002Fworker-{pr}.log`.\n\nCollect results; any non-fatal failure marks that PR skipped but continues the train.\n\nSee `references\u002Ffull-protocol.md §Phase 5` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-5-RebaseWave --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase5TaskId, status: \"completed\")\n\n## Phase 6 - Smoke Verify\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-6-SmokeVerify\")\n    TaskCreate(subject: \"PR-MERGE › Phase 6 - Smoke Verify\", activeForm: \"Running smoke verification after merges\")\n\nAfter all wave merges, run:\n```bash\nmvn test\n```\nOn failure: set state `FAILED`, emit `SMOKE_TEST_FAILED`, preserve worktree for diagnosis.\nOn success: advance to Phase 7.\n\nSee `references\u002Ffull-protocol.md §Phase 6` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-6-SmokeVerify --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase6TaskId, status: \"completed\")\n\n## Phase 7 - Report\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-7-Report\")\n    TaskCreate(subject: \"PR-MERGE › Phase 7 - Report\", activeForm: \"Writing merge-train completion report\")\n\nWrite `plans\u002Fmerge-train\u002F{trainId}\u002Freport.md` with: PRs merged, waves executed, errors encountered, total duration. Update `state.json` to `phase: COMPLETED`. Cleanup worktrees of successfully merged PRs via `x-manage-worktrees cleanup`.\n\nSee `references\u002Ffull-protocol.md §Phase 7` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode final --skill x-manage-pr-merge-train --phase Phase-7-Report --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Freport.md,plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase7TaskId, status: \"completed\")\n\n## Full Protocol\n\n> Full 8-phase workflow (Phase 0 Preparation → Phase 7 Report + Cleanup), `state.json` complete\n> schema, atomic-write pattern, `--resume` logic, rebase-subagent canonical prompt, file-overlap\n> precheck algorithm, and VETO evaluation rules in [`references\u002Ffull-protocol.md`](references\u002Ffull-protocol.md).\n","## Global Output Policy\n\n- **Language**: English ONLY.\n- **Tone**: Technical, Direct, and Concise.\n- **Efficiency**: Remove all conversational fillers. Start directly with technical information.\n- **Progress lines**: Prefix with the current phase, e.g. `[Phase 0]`, `[Phase 1]`, `[Phase 2]`.\n\n## Triggers\n\n```\n\u002Fx-manage-pr-merge-train --epic 0042 --dry-run\n\u002Fx-manage-pr-merge-train --prs 374,375,376\n\u002Fx-manage-pr-merge-train --pattern \"feat\u002Ftask-0042-\" --max-parallel 2\n\u002Fx-manage-pr-merge-train --epic 0042 --resume\n```\n\n## Parameters\n\n| Flag | Type | Required | Default | Description |\n| :--- | :--- | :--- | :--- | :--- |\n| `--prs` | `String` (CSV integers) | Mutually exclusive¹ | — | Literal comma-separated PR numbers; order preserved. |\n| `--epic` | `String` (4-digit ID) | Mutually exclusive¹ | — | Reads `ai\u002Fepics\u002Fepic-{ID}\u002Fexecution-state.json` to resolve PRs. |\n| `--pattern` | `String` (GitHub search regex) | Mutually exclusive¹ | — | Enumerates open PRs via `gh pr list --search`. Sorted by `createdAt`. |\n| `--max-parallel` | `Integer` | Optional | `3` | Max concurrent rebase workers in Phase 5 (1–8). |\n| `--dry-run` | Flag | Optional | `false` | Report plan and VETOs without merging. Exits after Phase 2. |\n| `--resume` | Flag | Optional | `false` | Resume interrupted train from `plans\u002Fmerge-train\u002F{id}\u002Fstate.json`. |\n\n> ¹ Exactly one of `--prs`, `--epic`, or `--pattern` must be provided; zero or multiple emits `MODE_AMBIGUOUS`.\n\n## Output Contract\n\n| Artifact | Path | Description |\n| :--- | :--- | :--- |\n| `state.json` | `plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json` | Full train lifecycle state; survives interruptions and supports `--resume`. |\n| `report.md` | `plans\u002Fmerge-train\u002F{trainId}\u002Freport.md` | Human-readable completion report: PRs merged, waves, errors, duration. |\n| `worker-{pr}.log` | `plans\u002Fmerge-train\u002F{trainId}\u002Fworker-{pr}.log` | Per-PR rebase worker result: `{status, headSha, durationMs, reason?}`. |\n\nTrain state transitions: `PREPARATION → DISCOVERY → VALIDATION → SORTING → MERGING_BASE → WAVE_N_DISPATCHED → WAVE_N_RETURNED → VERIFYING → REPORTING → COMPLETED` (or `FAILED`).\n\n## Error Envelope\n\n| Code | Phase | Condition | Remediation |\n| :--- | :--- | :--- | :--- |\n| `MODE_AMBIGUOUS` | 1 | 0 or 2+ mode flags | Provide exactly one of `--prs`, `--epic`, `--pattern`. |\n| `EPIC_STATE_MISSING` | 1 | `--epic N` but no `execution-state.json` | Use `--prs` or `--pattern`. |\n| `PR_CLOSED` | 2 | `state != \"OPEN\"` | Remove from train or reopen. |\n| `PR_DRAFT` | 2 | `isDraft == true` | Mark PR as Ready for review. |\n| `PR_BASE_MISMATCH` | 2 | `baseRefName != \"develop\"` | Rebase PR against develop. |\n| `PR_NOT_APPROVED` | 2 | `reviewDecision != \"APPROVED\"` | Request review. |\n| `PR_CI_FAILING` | 2 | CI has `FAILURE`\u002F`ERROR` check | Fix CI. |\n| `PR_MERGE_CONFLICT` | 2 | `mergeable == \"CONFLICTING\"` | Rebase manually. |\n| `NEUTERED_PARALLEL` | 3 | Code-file overlap detected (advisory, non-fatal) | `MAX_PARALLEL=1` forced; train continues serially. |\n| `MERGE_REJECTED_BY_PROTECTION` | 4–5 | Branch protection blocks merge | Adjust protection rules. |\n| `MERGE_POLL_TIMEOUT` | 4–5 | PR did not reach `MERGED` within timeout | Increase `--merge-timeout-seconds` or investigate CI. |\n| `CODE_CONFLICT_NEEDS_HUMAN` | 5 | Rebase conflict in non-golden file | Resolve manually → `git rebase --continue` → push → `--resume`. |\n| `PUSH_LEASE_REJECTED` | 5 | `--force-with-lease` rejected after retry | Fetch + rebase manually → `--resume`. |\n| `GOLDENS_REGEN_FAILED` | 5 | `GoldenFileRegenerator` non-zero | Diagnose build failure; see worker log. |\n| `SMOKE_TEST_FAILED` | 6 | `mvn test` fails after all merges | Diagnose; worktree preserved for diagnosis. |\n| `STATE_CONFLICT` | resume | No `state.json` or ambiguous train ID | Start fresh or provide `--train-id`. |\n\n## Phase Overview (Rule 25 — Task Hierarchy)\n\nEight phases (Rule 25 REGRA-001, EPIC-0055). Each opens with a PRE gate + `TaskCreate`, closes with a POST\u002FFINAL gate + `TaskUpdate(completed)`. Phase 0 is exempted from gates (read-only setup). Full per-phase implementation in `references\u002Ffull-protocol.md`.\n\n```\n0. PREPARATION  → detect state file, parse args, validate mode flag (inline)\n1. DISCOVERY    → enumerate PRs for the chosen mode (inline + gh CLI)\n2. VALIDATION   → VETO check per PR — open, non-draft, approved, CI pass (inline)\n3. SORTING      → topological sort + overlap pre-check (inline)\n4. BASE-MERGE   → merge base wave into develop (x-merge-pr per PR)\n5. REBASE-WAVE  → parallel rebase workers per wave (subagents)\n6. SMOKE-VERIFY → mvn test after all merges (inline)\n7. REPORT       → write report.md + cleanup (inline)\n```\n\nState machine: `PREPARATION → DISCOVERY → VALIDATION → SORTING → MERGING_BASE → WAVE_N_DISPATCHED → WAVE_N_RETURNED → VERIFYING → REPORTING → COMPLETED` (or `FAILED`).\n\n\u003C!-- phase-no-gate: read-only arg parsing and state-file detection; no artifact produced -->\n## Phase 0 - Preparation\n\nOpen a phase tracker (close with `TaskUpdate(id: phase0TaskId, status: \"completed\")` at end of setup):\n\n    TaskCreate(subject: \"PR-MERGE › Phase 0 - Preparation\", activeForm: \"Preparing merge-train setup\")\n\nResolve `--resume` (load existing `state.json`) vs fresh run. Validate exactly one of `--prs`, `--epic`, `--pattern`. Produce `trainId` (derived from mode + epoch). Errors: `MODE_AMBIGUOUS`, `EPIC_STATE_MISSING`, `STATE_CONFLICT`.\n\nSee `references\u002Ffull-protocol.md §Phase 0` for full implementation.\n\nPersist interactiveMode to state file (EPIC-0068 — consumed by Stop hook `enforce-continuous-flow.sh`):\n\n    Skill(skill: \"x-internal-update-status\", args: \"--file plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json --type merge-train --id {trainId} --field interactiveMode --value \u003Cinteractive|non-interactive>\")\n\nValue: `\"interactive\"` when `--interactive` passed or `CLAUDE_LEGACY_INTERACTIVE=1`; otherwise `\"non-interactive\"` (Rule 20 default, EPIC-0061).\n\n    TaskUpdate(id: phase0TaskId, status: \"completed\")\n\n## Phase 1 - Discovery\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-1-Discovery\")\n    TaskCreate(subject: \"PR-MERGE › Phase 1 - Discovery\", activeForm: \"Discovering PRs for merge train\")\n\nEnumerate PRs per chosen mode:\n- `--prs`: parse CSV, preserve order.\n- `--epic`: read `ai\u002Fepics\u002Fepic-{ID}\u002Fexecution-state.json`, collect merged story PR URLs.\n- `--pattern`: `gh pr list --search {pattern} --state open --json number,createdAt | sort by createdAt`.\n\nWrite initial `state.json` at `plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json` with `phase: DISCOVERY` and the discovered PR list. Advance state to `VALIDATION`.\n\nSee `references\u002Ffull-protocol.md §Phase 1` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-1-Discovery --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase1TaskId, status: \"completed\")\n\n## Phase 2 - Validation\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-2-Validation\")\n    TaskCreate(subject: \"PR-MERGE › Phase 2 - Validation\", activeForm: \"Validating PR merge eligibility\")\n\nFor each discovered PR, query `gh pr view {N} --json state,isDraft,baseRefName,reviewDecision,mergeable,statusCheckRollup` and apply VETO rules:\n- `PR_CLOSED`: `state != OPEN`\n- `PR_DRAFT`: `isDraft == true`\n- `PR_BASE_MISMATCH`: `baseRefName != develop`\n- `PR_NOT_APPROVED`: `reviewDecision != APPROVED`\n- `PR_CI_FAILING`: any check with `FAILURE` or `ERROR`\n- `PR_MERGE_CONFLICT`: `mergeable == CONFLICTING`\n\nIf `--dry-run`: print VETO report and exit after Phase 2. Non-vetoed PRs advance to Phase 3.\n\nSee `references\u002Ffull-protocol.md §Phase 2` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-2-Validation --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase2TaskId, status: \"completed\")\n\n## Phase 3 - Sorting\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-3-Sorting\")\n    TaskCreate(subject: \"PR-MERGE › Phase 3 - Sorting\", activeForm: \"Sorting and overlap-checking PRs\")\n\nTopological sort validated PRs by `createdAt` (or explicit `--prs` order). Run file-overlap pre-check against each pair: if code-file overlap detected, emit `NEUTERED_PARALLEL` advisory and force `MAX_PARALLEL=1` (serial). Update `state.json` with sorted order and parallelism decision.\n\nSee `references\u002Ffull-protocol.md §Phase 3` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-3-Sorting --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase3TaskId, status: \"completed\")\n\n## Phase 4 - Base Merge\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-4-BaseMerge\")\n    TaskCreate(subject: \"PR-MERGE › Phase 4 - Base Merge\", activeForm: \"Merging base PRs into develop\")\n\nFor each PR in sorted order, invoke `x-merge-pr`:\n\n    Skill(skill: \"x-merge-pr\", args: \"--pr {N} --strategy squash --target develop\")\n\nOn `MERGE_REJECTED_BY_PROTECTION` or `MERGE_POLL_TIMEOUT`: abort train with state `FAILED`. Record failed PR in `state.json`. See `references\u002Ffull-protocol.md §Phase 4`.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-4-BaseMerge --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase4TaskId, status: \"completed\")\n\n## Phase 5 - Rebase Wave\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-5-RebaseWave\")\n    TaskCreate(subject: \"PR-MERGE › Phase 5 - Rebase Wave\", activeForm: \"Rebasing PR wave onto develop\")\n\nDispatch rebase workers in parallel (up to `--max-parallel` sibling agents per wave). Each worker:\n1. Creates worktree via `x-manage-worktrees`.\n2. Rebases branch onto develop HEAD.\n3. On `GOLDENS_REGEN_FAILED`: runs `GoldenFileRegenerator` and re-pushes.\n4. On `CODE_CONFLICT_NEEDS_HUMAN`: preserves worktree, marks PR `FAILED`, continues.\n5. Writes result to `plans\u002Fmerge-train\u002F{trainId}\u002Fworker-{pr}.log`.\n\nCollect results; any non-fatal failure marks that PR skipped but continues the train.\n\nSee `references\u002Ffull-protocol.md §Phase 5` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-5-RebaseWave --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase5TaskId, status: \"completed\")\n\n## Phase 6 - Smoke Verify\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-6-SmokeVerify\")\n    TaskCreate(subject: \"PR-MERGE › Phase 6 - Smoke Verify\", activeForm: \"Running smoke verification after merges\")\n\nAfter all wave merges, run:\n```bash\nmvn test\n```\nOn failure: set state `FAILED`, emit `SMOKE_TEST_FAILED`, preserve worktree for diagnosis.\nOn success: advance to Phase 7.\n\nSee `references\u002Ffull-protocol.md §Phase 6` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode post --skill x-manage-pr-merge-train --phase Phase-6-SmokeVerify --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase6TaskId, status: \"completed\")\n\n## Phase 7 - Report\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode pre --skill x-manage-pr-merge-train --phase Phase-7-Report\")\n    TaskCreate(subject: \"PR-MERGE › Phase 7 - Report\", activeForm: \"Writing merge-train completion report\")\n\nWrite `plans\u002Fmerge-train\u002F{trainId}\u002Freport.md` with: PRs merged, waves executed, errors encountered, total duration. Update `state.json` to `phase: COMPLETED`. Cleanup worktrees of successfully merged PRs via `x-manage-worktrees cleanup`.\n\nSee `references\u002Ffull-protocol.md §Phase 7` for full implementation.\n\n    Skill(skill: \"x-internal-verify-phase-gates\", model: \"haiku\", args: \"--mode final --skill x-manage-pr-merge-train --phase Phase-7-Report --expected-artifacts plans\u002Fmerge-train\u002F{trainId}\u002Freport.md,plans\u002Fmerge-train\u002F{trainId}\u002Fstate.json\")\n    TaskUpdate(id: phase7TaskId, status: \"completed\")\n\n## Full Protocol\n\n> Full 8-phase workflow (Phase 0 Preparation → Phase 7 Report + Cleanup), `state.json` complete\n> schema, atomic-write pattern, `--resume` logic, rebase-subagent canonical prompt, file-overlap\n> precheck algorithm, and VETO evaluation rules in [`references\u002Ffull-protocol.md`](references\u002Ffull-protocol.md).\n",{"name":5,"description":7,"allowed-tools":24,"argument-hint":25,"context-budget":26,"user-invocable":27,"requires-capabilities":28},"Read, Write, Edit, Bash, Grep, Glob, Skill, Agent, TaskCreate, TaskUpdate","[--prs N,M,...] [--epic ID] [--pattern regex] [--max-parallel N] [--dry-run] [--resume]","medium",true,[],"main","952a630c6f38d193a349d86fa18db1de8843e837","src\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring-fintech-pci\u002F.claude\u002Fskills\u002Fx-manage-pr-merge-train",1,"https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment","https:\u002F\u002Fgithub.com\u002Freview-bench","https:\u002F\u002Freview-bench.ai","An open benchmark for AI code review.","2026-10-27 06:56:37",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":27},[40,43,46],{"tool":41,"command":42},"npx","npx skills add review-bench\u002Federcnj_ia-dev-environment --skill x-manage-pr-merge-train",{"tool":44,"command":45},"bunx","bunx skills add review-bench\u002Federcnj_ia-dev-environment --skill x-manage-pr-merge-train",{"tool":47,"command":48},"pnpm","pnpm dlx skills add review-bench\u002Federcnj_ia-dev-environment --skill x-manage-pr-merge-train","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring-fintech-pci\u002F.claude\u002Fskills\u002Fx-manage-pr-merge-train\u002FSKILL.md",[51],{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"references\u002Ffull-protocol.md","REFERENCE","参考文档",13450,"https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring-fintech-pci\u002F.claude\u002Fskills\u002Fx-manage-pr-merge-train\u002Freferences\u002Ffull-protocol.md",[58,65,72,79,86,93],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M757M8J48TQ1Y3X25GSJBXAS","x-parallel-eval","Detects and classifies file-collision risks between work units (tasks, stories, or epic phases) before parallel execution. Reads ## File Footprint blocks produced by x-task-plan \u002F x-story-plan, applies the parallelism-heuristics knowledge pack (hard \u002F regen \u002F soft categories + hotspot overrides), and emits a collision matrix + serialization recommendation in Markdown (default) or JSON.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fx-parallel-eval\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M757M57XMR9546S69466HDWT","parallelism-heuristics","Canonical catalog of file-collision heuristics for parallel task, story, and epic execution. Defines the File Footprint block format, the three Conflict Categories (hard \u002F regen \u002F soft), a hotspot list of high-contention paths, and the degrade-with-warning policy. Consumed by x-task-plan, x-story-plan, x-epic-map, x-parallel-eval, and x-dev-*-implement.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fparallelism-heuristics\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M757M11SZ8P1VCQABT08QVYA","x-watch-pr-ci","Polls a PR's CI checks and Copilot review status, blocking until checks complete or timeout. Returns one of 8 stable exit codes (SUCCESS=0, CI_PENDING_PROCEED=10, CI_FAILED=20, TIMEOUT=30, PR_ALREADY_MERGED=40, NO_CI_CONFIGURED=50, PR_CLOSED=60, PR_NOT_FOUND=70). Writes a versioned state-file for session resume.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-watch-pr-ci\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M757KW53K8KFPGADFB4PH949","x-validate-docs","Documentation freshness gate: validates 6 dimensions (readme, api-specs, grpc-proto, adr, skill-docs, system-architecture) against code changes in a PR. Stack-aware — only validates targets declared\u002Fauto-detected from ProjectConfig.documentation.targets. Returns exit non-zero on staleness; produces structured report.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-validate-docs\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M757KQZHSA10MKC0CR571D60","x-update-system-architecture","Incrementally updates docs\u002Farchitecture\u002Fsystem.md after an epic completes. Appends new entries to the Decision Log (§11) using x-internal-write-report --append (dedup by ## ID: marker) and surgically inserts component\u002Fintegration changes into sections 1-10 via Edit. Idempotent: re-running with the same epic produces a byte-identical system.md.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-update-system-architecture\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M757KKBT5Q1SVF8DMJBVF46M","x-update-architecture","Incrementally updates the service architecture document with changes from architecture plans. Adds new components, integrations, flows, and ADR references without rewriting existing content. Use after implementation to keep architecture documentation current.","https:\u002F\u002Fgithub.com\u002Freview-bench\u002Federcnj_ia-dev-environment\u002Fblob\u002Fmain\u002Fsrc\u002Ftest\u002Fresources\u002Fgolden\u002Fjava-spring\u002Fplatform-claude-code\u002F.claude\u002Fskills\u002Fx-update-architecture\u002FSKILL.md",[],[]]