Create Pull Request
Adapted from PRPs-agentic-eng by Wirasm. Part of the PRP workflow series.
Input: $ARGUMENTS — optional, may contain a base branch name and/or flags (e.g., --draft).
Parse $ARGUMENTS:
- Extract any recognized flags (
--draft) - Treat remaining non-flag text as the base branch name
- Default base branch to
mainif none specified
Phase 1 — VALIDATE
Check preconditions:
git branch --show-current
git status --short
git log origin/<base>..HEAD --oneline| Check | Condition | Action if Failed |
|---|---|---|
| Not on base branch | Current branch ≠ base | Stop: "Switch to a feature branch first." |
| Clean working directory | No uncommitted changes | Warn: "You have uncommitted changes. Commit or stash first. Use /prp-commit to commit." |
| Has commits ahead | git log origin/<base>..HEAD not empty | Stop: "No commits ahead of <base>. Nothing to PR." |
| No existing PR | gh pr list --head <branch> --json number is empty | Stop: "PR already exists: #<number>. Use gh pr view <number> --web to open it." |
If all checks pass, proceed.
Phase 2 — DISCOVER
PR Template
Search for PR template in order:
.github/PULL_REQUEST_TEMPLATE/directory — if exists, list files and let user choose (or usedefault.md).github/PULL_REQUEST_TEMPLATE.md.github/pull_request_template.mddocs/pull_request_template.md
If found, read it and use its structure for the PR body.
Commit Analysis
git log origin/<base>..HEAD --format="%h %s" --reverseAnalyze commits to determine:
- PR title: Use conventional commit format with type prefix —
feat: ...,fix: ..., etc.- If multiple types, use the dominant one
- If single commit, use its message as-is
- Change summary: Group commits by type/area
File Analysis
git diff origin/<base>..HEAD --stat
git diff origin/<base>..HEAD --name-onlyCategorize changed files: source, tests, docs, config, migrations.
PRP Artifacts
Check for related PRP artifacts:
.claude/PRPs/reports/— Implementation reports.claude/PRPs/plans/— Plans that were executed.claude/PRPs/prds/— Related PRDs
Reference these in the PR body if they exist.
Phase 3 — PUSH
git push -u origin HEADIf push fails due to divergence:
git fetch origin
git rebase origin/<base>
git push -u origin HEADIf rebase conflicts occur, stop and inform the user.
Phase 4 — CREATE
With Template
If a PR template was found in Phase 2, fill in each section using the commit and file analysis. Preserve all template sections — leave sections as "N/A" if not applicable rather than removing them.
Without Template
Use this default format:
## Summary
<1-2 sentence description of what this PR does and why>
## Changes
<bulleted list of changes grouped by area>
## Files Changed
<table or list of changed files with change type: Added/Modified/Deleted>
## Testing
<description of how changes were tested, or "Needs testing">
## Related Issues
<linked issues with Closes/Fixes/Relates to #N, or "None">Create the PR
gh pr create \
--title "<PR title>" \