
create-github-pr
Create a GitHub pull request with generated description
by ashneyderman|Open Source
Create GitHub PR
Create a GitHub pull request with an auto-generated description based on branch commits.
Instructions
Extract the agf_id parameter to use as a prefix for the PR title.
- Generate PR Title: Create a PR title prefixed with
<agf_id> -followed by a descriptive title based on the changes - Generate PR Body:
- IF the project contains
.github/PULL_REQUEST_TEMPLATE.md:- Use the template to structure the PR body
- Fill in sections based on all commits on the current branch that are not in main/master branch
- ELSE:
- Generate a brief but precise description
- Include summary of all commits on the current branch that are not in main/master branch
- IF the project contains
- Verify Clean State: Use
git status --porcelainto check for uncommitted changes- If any uncommitted changes exist, exit with an error message
- Push Changes: Push all changes to remote branch using
git push --set-upstream origin $(git branch --show-current) - Create or Display PR:
- Check if PR already exists using
gh pr view - IF PR exists: Print "PR already exists"
- ELSE: Create draft PR using
gh pr create --draft --title "<pr_title>" --body "<pr_body>"
- Check if PR already exists using
Report
Print the result of the gh pr view command to display the PR URL and details.
Example
agf_id: agf-001
PR Title: agf-001 - Add user authentication feature
PR URL: https://github.com/owner/repo/pull/123