Merge pr

From ianjamesburke/PLEXI · View interactive version

Merge pr is an AI agent skill from the GitHub repository ianjamesburke/PLEXI. Phase 4 of the PLEXI ship pipeline. Takes an approved PR number, squash-merges to alpha, closes the issue, and cleans up. Input: PR number. Output: merged alpha.

How to use this skill

Skill file

Merge PR

Phase 4 of the ship pipeline. Input: approved PR number. Output: clean alpha with the PR merged. Version bumps happen later at release-batch or promotion time.

Labels are the live state. On success, all pipeline:* labels are removed when the issue closes. On failure, remove all pipeline:* labels and in progress, add ready.

Stint timing closure. Close linked stint tasks with stint done <task-id> after the script exits 0.

Pane slots. Source .agents/skills/_lib/pipeline-slots.sh and publish pipeline_slots_set merge "$ISSUE" "$PR_NUMBER" <status> "" <last-error> at status changes.

Entry: /merge-pr <pr-number>


Step 0 — Set CWD and Flip Pane Status

cd "$(git rev-parse --show-toplevel)"
plexi${PLEXI_CHANNEL:+-$PLEXI_CHANNEL} pane name "#<n> · merging"
pipeline_slots_set merge "$ISSUE" "$PR_NUMBER" merging "" ""

Labels are already correct when invoked inline from validate-pr. No label edit needed here.


Step 1 — Run the Merge Script

just bs-merge <PR_NUMBER> --reviewed-head <FULL_REVIEWED_SHA>
# or: just merge-pr <PR_NUMBER> --reviewed-head <FULL_REVIEWED_SHA>

Verifies the reviewed head, squash-merges it, fast-forwards Alpha, retires only that PR channel and clean worktree, and closes linked tasks and issues. If the PR is behind Alpha, rebase separately and repeat validation and independent review.

If it exits non-zero, read the error and recover with sub-steps:

| Error | Recovery |

|-------|----------|

| PR behind Alpha | Rebase the lane, repeat applicable validation and independent review, then retry with the new reviewed SHA |

| PR already merged | just merge-sync && just merge-cleanup $PR $BRANCH <SHA> && just merge-close <ISSUE> $PR && just merge-close-stints $PR <STINT...> |

| Local edit conflicts with the PR or Alpha sync | Preserve the edit and resolve the conflict before retrying |

| Diverged local alpha | Investigate and preserve local commits; do not reset |

| Ignored lane content | Merge completes and the lane is retained. Preserve or deliberately handle the listed files before retrying cleanup; Git removes ignored files with the worktree |

| could not resolve GitHub issue or stint tasks | Only if the PR genuinely has nothing to close (standalone follow-up): just merge-pr $PR --reviewed-head <SHA> no-issue. Otherwise fix the PR body's Stint: <id> or closing keyword first. |

Available sub-steps:

just merge-rebase <BRANCH>       # fetch + rebase feature branch on origin/alpha + force-push
just merge-squash <PR> <SHA>     # squash-merge reviewed SHA only
just merge-sync                  # fast-forward only, preserving local work
just merge-cleanup <PR> <BRANCH> <SHA> # clean PR channel and clean lane only
just merge-close <ISSUE> <PR>    # strip pipeline labels + close issue + append ship log
just merge-close-stints <PR> <STINT...>  # mark stints done

Step 2 — Verify Linked Stints & Update `TRUTH.md`

just merge-pr automatically runs stint done <id> for stints resolved from the PR body (Stint: <id>), branch name (feature/stint-<id>-*), or gh_issue: frontmatter. Confirm they are marked done:

stint show <task-id>

If estimate was off >2x, add one sentence to the task body explaining why.

Update TRUTH.md at the repo root with the merged PR and stint status (per AGENTS.md).


Step 3 — Unblock Downstream Issues (if GitHub issue-backed)

gh issue-ext blocking list $ISSUE --json number,title,state 2>/dev/null

For each open blocked issue, check if all blockers are now closed. If so:

gh issue edit <n> --remove-label "blocked" --add-label "ready"

Step 4 — Complete and Close Pane

git status  # must be clean

Output exactly this block — nothing after it, no RECOMMENDATION:

[COMPLETE]

| | |
|---|---|
| PR | #<n> — <title> |
| Issue | #<issue> — <title> / no-issue |
| Alpha | <short-sha> |
| Stint | <task-id> closed / none |
plexi${PLEXI_CHANNEL:+-$PLEXI_CHANNEL} pane name "#<n> · done"
pipeline_slots_set merge "$ISSUE" "$PR_NUMBER" done "" ""
plexi pane slot write status merge:done --pane-id $PLEXI_PANE_ID --replace
plexi${PLEXI_CHANNEL:+-$PLEXI_CHANNEL} pane close

Soft exit (deferred threads): use needs-you pane status instead of done; do not call plexi pane close.


Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.