| name | merge-and-branch |
| description | Squash-merge the current PR into main, delete the branch, pull latest, and start a new feature branch. Use when the user says "merge this PR", "merge and start new branch", or is done with a PR and ready to start the next task. |
| allowed-tools | Bash(gh pr view:*), Bash(gh pr merge:*), Bash(git checkout:*), Bash(git pull:*), Bash(git branch:*), Bash(git status:*) |
Merge PR and Create Branch
I have gathered information about the current PR and git state. Here are the results:
<current_pr>
!gh pr view --json number,title,state,url,headRefName
</current_pr>
<current_branch>
!git rev-parse --abbrev-ref HEAD
</current_branch>
<git_status>
!git status --short
</git_status>
Instructions
Step 1: Verify PR is ready
- Check the PR state - ensure it's OPEN and ready to merge.
- Check for uncommitted changes - warn if there are local changes that might be lost.
Step 2: Merge the PR
- Merge with squash and delete the branch:
gh pr merge <number> --squash --delete-branch
Step 3: Switch to main
- Checkout main and pull latest:
git checkout main && git pull
Step 4: Create new branch
-
Ask the user for the new branch name using AskUserQuestion tool.
-
Create the branch:
git checkout -b <branch-name>
-
Confirm the new branch was created with git branch --show-current.