GitHub PR Create
Create a PR from a conventional branch to main using GitHub CLI.
Workflow
- •Confirm
ghauthentication:gh auth status. - •Confirm current branch and policy:
- •Must be on
feature/*,chore/*,fix/*,docs/*,refactor/*, ortest/*(notmain).
- •Ensure the branch is pushed:
git push -u origin <branch>. - •If behavior/logic changed, verify tests were added or updated before PR creation.
- •Create PR targeting
main. - •Return the PR URL to the user.
Preferred Commands
- •Status:
git status -sb - •Branch:
git branch --show-current - •Push:
git push -u origin <branch> - •PR create (auto-fill):
gh pr create --base main --head <branch> --title "<title>" --fill - •PR create (explicit body):
gh pr create --base main --head <branch> --title "<title>" --body "<body>"
Bundled Script
Use scripts/pr_create.sh for a consistent flow:
code
./scripts/pr_create.sh ["<title>"] ["<body>"] [base]
Behavior:
- •Enforces conventional branch prefixes.
- •Pushes the current branch if needed.
- •Defaults base to
main. - •If title/body are omitted, generates them from branch name and commits.
Notes
- •If
gh auth statusfails, rungh auth loginfirst. - •If there are uncommitted changes, stop and ask the user to commit.
- •If behavior changed but tests were not updated, request/perform test updates before opening PR.