gh-pr-create
Scannednpx machina-cli add skill saadjs/agent-skills/gh-pr-create --openclawGitHub 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).
Source
git clone https://github.com/saadjs/agent-skills/blob/main/skills/gh-pr-create/SKILL.mdView on GitHub Overview
gh-pr-create automates opening a GitHub PR with the gh CLI once git-incremental-commits finishes and the working tree is clean. It pushes the branch, chooses the base branch, and creates a PR body with a Summary and Major changes, plus optional Screenshots, Tests, and Additional info. After creation, it prompts for reviewers to streamline feedback.
How This Skill Works
The tool validates a clean working tree on a non-main PR branch, pushes the branch if needed, determines the default base branch, and runs gh pr create with a body built from mandatory sections. The PR title defaults to a Conventional Commit style derived from recent commits, and can be overridden with PR_TITLE.
When to Use It
- After git-incremental-commits finishes and you want to open a PR on a feature branch.
- When someone asks you to make a PR or says to 'make a PR'.
- When you need to push your branch and create a PR with a standardized body.
- When you want gh pr create to determine the base branch automatically and use a consistent PR body format.
- When you plan to request reviewers (e.g., copilot, codex, or specific GitHub usernames) after PR creation.
Quick Start
- Step 1: Ensure git status -sb is clean and you are on a non-main branch.
- Step 2: Push the branch if needed (git push -u origin HEAD or git push).
- Step 3: Run gh pr create with a derived title and a body file; after PR creation, provide reviewers as needed.
Best Practices
- Ensure you are on a non-main branch and the working tree is clean before starting the PR process.
- Give a descriptive feature branch name and prefer a conventional-commit style title, or override with PR_TITLE if needed.
- Keep the PR body concise and focused: include Summary and Major changes, adding optional sections only if relevant.
- Only include Screenshots for UI changes and add Tests if a test command/CI is configured for the repo.
- After PR creation, use gh pr edit or gh pr comment to add reviewers using copilot, codex, or specific usernames.
Example Use Cases
- Feat: Add search by tag; PR body includes Summary and Major changes.
- Fix: Patch login regression; PR body includes Major changes and Tests.
- Docs: Update usage in README; PR body includes Summary only.
- UI: Redesign header; PR body includes Screenshots and Major changes.
- Refactor: Core module cleanup; PR body includes Additional info about rollout.