Create Pull Request
Create a pull request or update an existing one following project conventions.
Usage
- •
/git-create-pr- Create PR to main - •
/git-create-pr <base-branch>- Create PR to specified base branch
Reference Files
- •@pr-body-template.md - PR body structure template
Instructions
- •
Gather context (run in parallel):
- •
git status- Check for uncommitted changes - •
git branch --show-current- Get current branch name - •
git log origin/main..HEAD --oneline- See commits to include (adjust base as needed) - •
git diff origin/main..HEAD --stat- See files changed
- •
- •
Check for uncommitted changes:
- •If there are uncommitted changes, ask user if they want to commit first
- •Do not proceed with PR creation if there are uncommitted changes
- •
Check for existing PR:
bashgh pr list --head <current-branch>
- •If a PR already exists, ask user: "PR #N already exists for this branch. Update its description instead of creating new?"
- •If yes, use
gh pr edit <number> --body "..."instead ofgh pr create
- •
Determine base branch:
- •If
$ARGUMENTSprovided, use that as base - •If branch name suggests a parent (e.g.,
feature/foo-part2might be based onfeature/foo), ask user - •Default to
main
- •If
- •
Check if push needed:
- •If local is ahead of remote, push first:
git push -u origin <branch>
- •If local is ahead of remote, push first:
- •
Create or update PR using the template from @pr-body-template.md
- •
Run the gh command:
For new PR:
bash
gh pr create --base <base-branch> --title "<title>" --body "$(cat <<'EOF' <body content> EOF )"
For existing PR:
bash
gh pr edit <number> --body "$(cat <<'EOF' <body content> EOF )"
- •Return the PR URL to the user.