| name | github-pr |
| description | Create a GitHub pull request after committing, rebasing, and pushing changes. Use when the user asks to create a PR, submit changes for review, or open a pull request. |
PyPTO GitHub Pull Request Workflow
Task Tracking
Create tasks to track progress through this workflow:
- Prepare branch & commit
- Check for existing PR
- Fetch upstream & rebase
- Push to remote
- Create PR
Workflow Steps
- Prepare branch and commit (if on main or uncommitted changes)
- Check for existing PR (exit if found)
- Fetch upstream changes
- Rebase onto upstream/main
- Resolve conflicts if needed
- Push to fork with
--force-with-lease
- Create PR using gh CLI
Step 1: Prepare Branch and Commit
Check current state:
BRANCH_NAME=$(git branch --show-current)
git status --porcelain
git fetch upstream 2>/dev/null || git fetch origin
if git rev-parse --verify upstream/main >/dev/null 2>&1; then
BASE_REF=upstream/main
else
BASE_REF=origin/main
fi
git rev-list HEAD --not "$BASE_REF" --count
A branch "needs a new branch" when it is effectively on main โ either the branch name is main/master, or it has zero commits ahead of upstream/main (e.g., a local branch that was never diverged).
Decision logic:
| Needs new branch? | Uncommitted changes? | Action |
|---|
| Yes | Yes | Create new branch, then commit via /git-commit |
| Yes | No | Error โ nothing to PR. Tell user to make changes first |
| No | Yes | Commit on current branch via /git-commit |
| No | No | Skip โ already committed on a feature branch |
If a new branch is needed:
- Auto-generate a branch name with a meaningful prefix (
feat/, fix/, refactor/, chore/, docs/, test/) based on the changes โ do NOT ask the user
- Create and switch to the new branch:
git checkout -b <branch-name>
- Commit via
/git-commit skill (mandatory โ runs code review, testing, linting)
If on an existing feature branch with uncommitted changes:
Commit via /git-commit skill before proceeding.
Step 2: Check for Existing PR
BRANCH_NAME=$(git branch --show-current)
gh pr list --head "$BRANCH_NAME" --state open
If PR exists: Display with gh pr view and exit immediately.
Step 3: Fetch Upstream
git remote add upstream https://github.com/hw-native-sys/pypto.git
git fetch upstream
Step 4: Rebase
git rebase upstream/main
On conflicts:
git status
git add path/to/resolved/file
git rebase --continue
Step 5: Push
git push --set-upstream origin BRANCH_NAME
git push --force-with-lease origin BRANCH_NAME
โ ๏ธ Use --force-with-lease - safer than --force, fails if remote has unexpected changes.
Step 6: Create PR
Check gh CLI:
gh auth status
If gh NOT available: Report to user and provide manual URL: https://github.com/hw-native-sys/pypto/compare/main...BRANCH_NAME
If gh available:
gh pr create \
--title "Brief description of changes" \
--body "$(cat <<'EOF'
## Summary
- Key change 1
- Key change 2
## Testing
- [ ] All tests pass
- [ ] Code review completed
- [ ] Documentation updated
## Related Issues
Fixes #ISSUE_NUMBER (if applicable)
EOF
)"
PR Title/Body: Auto-extracted from commit messages since upstream/main.
Important:
- โ Do NOT add footers like "๐ค Generated with Claude Code" or similar branding
- โ
Keep PR descriptions professional and focused on technical content only
Common Issues
| Issue | Solution |
|---|
| PR already exists | gh pr view then exit |
| Merge conflicts | Resolve, git add, git rebase --continue |
| Push rejected | git push --force-with-lease |
| gh not authenticated | Tell user to run gh auth login |
| Wrong upstream branch | Use git rebase upstream/BRANCH |
Checklist
Remember
- Always rebase before creating PR
- Use
--force-with-lease, not --force
- Don't auto-install gh CLI - let user do it