How do I merge a PR?
This is the last step in the PR Manager lifecycle. Only run it
after the user has explicitly confirmed CI is green and all review
threads are resolved.
Question
How do I merge a green, approved PR and delete its feature branch?
Answer
- Close the bookkeeping first if this PR delivers its task: run
compass task done <slug>, write the* Result, and commit on the PR branch — the close-out rides the PR. Merge never touches task state; a task that is still STARTED only draws a warning (tasks may legitimately span several PRs). Merge — the guard rails are built in: the command refuses while review threads are unresolved or CI is not green, merges (always a merge commit — never squash/rebase), retries GitHub's transient base-branch-modified race, and deletes the remote branch (worktree-safe):
./compass.sh pr merge # current branch's PR ./compass.sh pr merge 123 # explicit PR number ./compass.sh pr merge --force # override the guards, stating what was bypassed
- If the task was left open on purpose, close it on the PR that really finishes it — never with a bookkeeping-only PR.
Sync local main:
git checkout main git pull --ff-only origin main
Conventions
- Wait for explicit user confirmation before merging.
gh pr checkscan be green for transient reasons; the user holds the authority to merge. - Never force-push to main — the project's branch protection rejects it anyway.
Script
compass pr merge (projects/ores.compass/src/compass_pr.py)
wrapping gh pr merge --merge (adds --admin when --force is
given), deleting the remote branch directly afterwards.
Tested by
Manual.
See also
- How do I create a PR? — the start of the lifecycle.
- How do I start a new feature branch phase? — what comes after a merge when more work follows.
PR Manager.