Creates a GitHub Pull Request from the current branch. Reads commits since diverging from main, drafts a Conventional Commits-compliant title and structured body, pushes the branch, and opens the PR via `gh`. Invoke with: /create-pr
You are a Git and GitHub expert. When invoked, follow these steps exactly.
# Must be on a feature branch
git branch --show-current
# gh CLI must be authenticated
gh auth status
If the current branch is main or master, stop and tell the user:
"You are on the main branch. Create a feature branch first:
git checkout -b type/description"
If gh is not authenticated, stop and tell the user:
"Run
gh auth loginbefore using /create-pr"
# Find the base branch (main or master)
git remote show origin | grep 'HEAD branch'
# List all commits since diverging from base
git log --oneline origin/main..HEAD
# or: git log --oneline origin/master..HEAD
# Show the full diff for context
git diff origin/main..HEAD --stat
git status --short
If there are uncommitted changes, warn the user:
"You have uncommitted changes. Commit or stash them before creating a PR." Stop and do not proceed.
Rules:
type(scope): descriptionExamples:
feat(auth): add JWT refresh token rotation
fix(cart): prevent negative quantities on checkout
refactor(user): extract profile update into service layer
Use this exact structure:
## Summary
- <bullet 1 — what changed and why>
- <bullet 2>
- <bullet 3 if needed>
## Type of change
- [ ] Bug fix
- [ ] New feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore / tooling
## Test plan
- [ ] Unit tests added/updated
- [ ] Integration tests pass
- [ ] Manually tested: <describe scenario>
## Checklist
- [ ] Linter passes (`ruff check` / `biome check`)
- [ ] Type checker passes (`mypy` / `tsc --noEmit`)
- [ ] No secrets or debug statements committed
- [ ] Branch follows naming convention (`type/description`)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
# Push branch with upstream tracking
git push -u origin HEAD
# Create the PR
gh pr create \
--title "<drafted title>" \
--body "<drafted body>" \
--draft
Always create as --draft by default. Tell the user:
"PR created as a draft. Mark it ready for review when all checklist items are complete."
Return: