From 8734e7d835eff04af418118df520bc513a31fef6 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Thu, 12 Feb 2026 18:27:50 +0100 Subject: [PATCH] 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 --- .claude/skills/push-pr/SKILL.md | 109 ++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .claude/skills/push-pr/SKILL.md diff --git a/.claude/skills/push-pr/SKILL.md b/.claude/skills/push-pr/SKILL.md new file mode 100644 index 000000000..7413ac4f2 --- /dev/null +++ b/.claude/skills/push-pr/SKILL.md @@ -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/.. +``` + +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 +``` + +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 ``. PR #X updated." Done. +- **No PR**: Continue to step 6. + +### 6. Create a new PR + +```bash +git log --oneline main.. +git diff --stat main... +``` + +Draft title (`(): `, max 70 chars) and description. + +```bash +cat > /tmp/pr-body.md << 'EOF' +## Summary +... +EOF +tea pr create \ + --repo jpmschweitzer/settled-reach \ + --login schweitz \ + --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.