PR
Create a pull request with a well-structured summary.
Steps
-
Gather context:
- Detect the default branch:
gh repo view --json defaultBranchRef -q .defaultBranchRef.name - Get all commits since divergence:
git log <default>..HEAD --oneline - Get the full diff:
git diff <default>...HEAD --stat - Check if the branch is pushed:
git rev-list @{u}..HEAD --count 2>/dev/null
- Detect the default branch:
-
Push if needed: If there are unpushed commits, run
git push -u origin HEAD. -
Generate PR content:
- Title (if not provided): Derive from commits. If single commit, use its message. If multiple, summarize the theme (under 70 chars).
- Body: Use this format:
## Summary - <bullet points derived from commits, grouped by type> ## Test plan - [ ] <derived from what changed — e.g., "CI passes", "manual test of X">
-
Create PR: Run
gh pr create --title "<title>" --body "<body>"using a HEREDOC for the body. -
Report: Show the PR URL.
Rules
- Never create a PR if there are no commits ahead of the default branch.
- If a PR already exists for this branch, show its URL instead of creating a duplicate.
- Keep the title under 70 characters.
- Group commits by type (feat, fix, chore, etc.) in the summary.