/pr — Create Pull Request
Push the current branch and open a PR against: ${ARGUMENTS:-main}
Note: Use /pr for standalone PR creation outside the /implement workflow. If you're running /implement, it handles PR creation in Stage 7 — you don't need /pr separately.
Pre-flight
- •Verify GitHub CLI is authenticated:
bash
gh auth status
If not authenticated, STOP and tell the user to run gh auth login.
- •Verify not on main/master:
bash
BRANCH=$(git branch --show-current) if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then echo "ERROR: Cannot create PR from $BRANCH. Switch to a feature branch first." exit 1 fi
- •Verify a remote exists:
bash
git remote get-url origin 2>/dev/null || echo "ERROR: No remote 'origin'. Add one with: git remote add origin <url>"
If no remote, STOP and tell the user.
- •Check for uncommitted changes:
bash
git status --porcelain
If uncommitted changes exist, ask the user whether to commit them first.
- •Check if PR already exists:
bash
gh pr view --json url --jq '.url' 2>/dev/null
If a PR already exists, report its URL and ask if the user wants to update it.
Create PR
- •Push the branch:
bash
git push -u origin $(git branch --show-current)
- •Gather context for the PR description:
bash
git log ${ARGUMENTS:-main}..HEAD --oneline
git diff ${ARGUMENTS:-main}..HEAD --stat
- •Create the PR. If the branch name matches
task/<number>, includeCloses #<number>in the body:
bash
gh pr create \
--base ${ARGUMENTS:-main} \
--title "<concise title from commit messages>" \
--body "## Summary
<bullet points summarizing the changes>
## Changes
<output of git diff --stat>
Closes #<number-if-applicable>"
Post-create
- •Report the PR URL:
bash
gh pr view --json url --jq '.url'
- •Tell the user: "PR created. Run
/review <branch>for an agent review, or/dod <task-id>to run all gates."