Merge an ha PR
Input
$ARGUMENTS
Merging is the one irreversible step in the pipeline, so it gets a real gate. Confirm readiness with evidence before merging — never merge on assumption.
Step 1 — Preflight (all must pass)
PR="<pr-number from the arguments, or empty to auto-detect>"
[ -n "$PR" ] || PR="$(gh pr view --json number --jq .number 2>/dev/null)" # no number given -> current branch's PR
[ -n "$PR" ] || { echo "no PR number given and none found for the current branch" >&2; exit 1; }
gh pr view "$PR" --json state,mergeable,mergeStateStatus,reviewDecision,statusCheckRollup,headRefName,isDraft
Block the merge and report if any of these hold:
stateis not OPEN, orisDraftis true.reviewDecisionis CHANGES_REQUESTED (a human requested changes on GitHub). Do NOT require APPROVED: a/ha:review-prAPPROVE is a process gate that lands as a PR comment — it never setsreviewDecision(and the PR's own author cannot approve it on GitHub), so requiring APPROVED would block solo use forever.- CI (
statusCheckRollup) is not all-green. mergeableis false /mergeStateStatusindicates conflicts or out-of-date — in that case update from base first: run/ha:resolve-conflicts <pr>(it merges the base in the feature's isolated worktree and re-verifies), then re-run this skill.- There is unresolved blocking review feedback.
If anything fails, stop and say exactly what's missing — do not "force" it.
Step 2 — Merge
Default to the repo's convention (squash is common; respect any branch-protection rule). Delete the remote branch on merge to keep things tidy:
gh pr merge "$PR" --squash --delete-branch # or --merge / --rebase per repo norm
This follows superpowers:finishing-a-development-branch's ordering — merge
first, then reclaim the worktree (the next step), and never delete a branch that
still has unmerged work.
Step 3 — Confirm and hand off
gh pr view "$PR" --json state,mergedAt
result: PR #<n> merged.
Remind the user that once the PR is merged, its isolated worktree and local
branch can be reclaimed with /ha:clean-worktrees (it removes only
worktrees whose PR is verified merged).