merge
Use when the user invokes /merge - merges the current PR, cleans up, and pulls the default branch
Merge
Merge the PR for the current branch, clean up, and pull latest.
Steps
0. Pre-check: ensure committed and PR exists
- If there are staged/unstaged changes or untracked files, run the
/commitworkflow first. - If no PR exists for the current branch (
gh pr viewfails), run the/prworkflow first. - Then continue below.
1. Gather context
git branch --show-current— current branchgit remote show origin 2>/dev/null | grep 'HEAD branch'— default branchgh pr view --json state,mergeable,title— PR status
2. Merge
gh pr merge --squash --delete-branch- If merge fails (checks pending, reviews required), stop and tell the user why
3. Clean up and pull
If in a worktree (parent repo exists at ../<original-repo>):
cdback to the original repo directorygit worktree remove ../<worktree-dir>git checkout <default-branch> && git pull
If in the main repo:
git checkout <default-branch> && git pullgit branch -d <branch>(if not already deleted by--delete-branch)
4. Done
Confirm clean state with git status.
Rules
- Never force merge
- If PR is not mergeable, report the reason — don't work around it