GitHub PR Create (gh)
Goal
After $git-incremental-commits finishes (working tree clean), push the branch, open a PR with a consistent body format, then ask who to request review from.
Preconditions
- Repo is on a non-
main/masterbranch. git status -sbis clean.ghis installed and authenticated (gh auth status).
Workflow
Verify working tree is clean.
git status -sb- Stop if there are uncommitted changes.
Confirm you are on a branch suitable for a PR.
git branch --show-current- If on
main/masteror detached HEAD: stop and create/switch to a branch.
Ensure the branch is pushed.
- If no upstream is set:
git push -u origin HEAD - Otherwise:
git push
- If no upstream is set:
Determine PR base branch.
- Prefer the repo default branch:
gh repo view --json defaultBranchRef -q .defaultBranchRef.name
- Prefer the repo default branch:
Write a PR body in this format (human summary, not diffstats).
Include these headings exactly:
## Summary## Major changes
Conditionally include these headings:
## Screenshots: include only if relevant (UI changes or image diffs).## Tests: include only if the repo has a configured test command/CI expectation.## Additional info: include only if there is something non-obvious to call out (follow-ups, rollout notes, risks).
- Open the PR with
gh pr create.
Title:
- Default to a summarized Conventional Commit style title derived from the branch commits (e.g.
Feat: ...,Fix: ...,Docs: ...). - Override with
PR_TITLE="..."if needed.
- Default to a summarized Conventional Commit style title derived from the branch commits (e.g.
Body:
- Use
--bodyor--body-file:gh pr create --title "..." --body-file /tmp/pr-body.md
- Use
- After the PR is created, ask who to request review from.
Prompt the user for reviewers (GitHub usernames), supporting these special cases:
copilot: request review via the GitHub CLI reviewer option.codex: request review by commenting@codex reviewon the PR.
If the user chose
copilot:gh pr edit --add-reviewer copilot
If the user chose
codex:gh pr comment --body "@codex review"
If the user provided other reviewer usernames (e.g.
octocat,hubot):gh pr edit --add-reviewer octocat,hubot
If you need to explicitly target a PR (instead of relying on the current branch), resolve the PR number/URL first and pass it to the commands above:
gh pr view --json number,url -q .numbergh pr edit <number-or-url> --add-reviewer ...gh pr comment <number-or-url> --body "@codex review"
Notes
- Keep the PR body concise but specific.
- If there are multiple major changes, list them as bullets under
## Major changes. - If tests are not configured, omit the entire
## Testssection (do not include an empty heading). - Avoid including raw
git diff --statoutput in## Summary(GitHub already provides file-level diff context).
Converted and distributed by TomeVault — claim your Tome and manage your conversions.