chore(skills): add push-pr skill for safe PR lifecycle

Pushes current branch and creates or updates a PR without ever
merging into main. Prevents accidental PR merges by restricting
the skill to branch-side operations only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-12 18:27:50 +01:00
co-authored by Claude Opus 4.6
parent c83d129703
commit 8734e7d835
+109
View File
@@ -0,0 +1,109 @@
---
name: push-pr
description: >
Push commits and create or update a pull request. Use when the user says
"push pr", "push and create pr", "update pr", "create a pr", "open a pr",
or invokes /push-pr. NOT triggered by plain "push" (that's just git push).
Pushes the current branch, creates a PR if none exists, or confirms the
existing PR was updated. NEVER merges the PR into main — this skill only
pushes to the branch and manages the PR lifecycle.
user-invocable: true
allowed-tools: Bash, Read, Grep, Glob, AskUserQuestion
---
# Push PR Skill
Push commits to remote and create or update a PR. Operates exclusively on the
current branch — never touches main.
## Safety Rules (NON-NEGOTIABLE)
- **NEVER merge a PR into main.** No `tea pr merge`, no `git merge` into main.
- **NEVER checkout or push to main.**
- **NEVER force-push** unless the user explicitly requests it.
- **NEVER use `--no-verify` or skip hooks.**
- Only push to the current working branch.
## Workflow
### 1. Validate branch
```bash
git branch --show-current
```
If on `main`, stop: "You're on main. Switch to a team branch first."
### 2. Check for unpushed commits
```bash
git fetch --all
git status
git log --oneline origin/<branch>..<branch>
```
If no unpushed commits, skip to step 4 (PR check).
### 3. Check for conflicts with main
```bash
git merge-tree --write-tree origin/main HEAD 2>&1
```
If conflicts reported, merge main into current branch:
```bash
git merge origin/main --no-edit
```
If merge conflicts, **stop and report** — let the user resolve.
If clean, continue.
### 4. Push
```bash
git push origin <branch>
```
If push fails, stop and report. Never force-push without explicit request.
### 5. Check for existing PR
```bash
tea pr list --login schweitz --repo jpmschweitzer/settled-reach --state open --output simple
```
Match current branch name in PR list.
- **PR exists**: Report "Pushed N commits to `<branch>`. PR #X updated." Done.
- **No PR**: Continue to step 6.
### 6. Create a new PR
```bash
git log --oneline main..<branch>
git diff --stat main...<branch>
```
Draft title (`<type>(<scope>): <summary>`, max 70 chars) and description.
```bash
cat > /tmp/pr-body.md << 'EOF'
## Summary
...
EOF
tea pr create \
--repo jpmschweitzer/settled-reach \
--login schweitz \
--title "<title>" \
--description "$(cat /tmp/pr-body.md)" \
--base main \
--head <branch>
```
Report PR URL when done.
## Arguments
If the user passes arguments (e.g., `/push-pr "my title"`), use them as the
PR title instead of generating one.