| name | push-pr |
| description | Push current branch and create a GitHub PR if one doesn't exist |
| disable-model-invocation | true |
| allowed-tools | Bash(gh *), Bash(git *) |
Push and Create PR
Steps
- Parse the target branch (the branch to open a PR against) from the arguments. Pull latest for that branch before doing anything. Always create a new branch from the target branch — do not continue on the current branch.
- If there are uncommited files, commit them, adding an appropriate commit message of a short to medium length.
- Lint and build the affected packages. API build might fail because of Sentry misconfiguration - ignore that. Otherwise, try to lint and build everything.
- Run the tests. If those fail - stop the execution of the following steps and propose steps to resolve the issue.
- Get the current branch name with
git rev-parse --abbrev-ref HEAD
- Push the branch:
git push -u origin "$BRANCH"
- Check if a PR already exists:
gh pr list --head "$BRANCH" --json number,url --jq '.[0]'
- If no PR exists:
- Run
git diff main...HEAD and git log main..HEAD --oneline to understand ALL changes on the branch
- Create a PR with
gh pr create using a descriptive title and body based on the actual changes
- If a PR already exists:
- Print the existing PR URL
PR format
Use this format for gh pr create:
gh pr create --title "short title under 70 chars" --body "$(cat <<'EOF'
## Summary
<detailed summary of what changed, why, tradeoffs if needed>
## Test plan
- [ ] relevant test checklist items
EOF
)"
Rules
- Never force-push
- Keep the PR title under 70 characters
- The body should summarize the "why", not just list files
- If the branch has no commits ahead of main, stop and tell the user