hanamizuki/solopreneur/merge-pr
Claude Code and agent skill by hanamizuki/solopreneur
- community
Checking that the SKILL.md file is still in the repository.
Merge an open PR for the current branch. Refuses to merge when the worktree has uncommitted changes, consolidates the branch's plan file (renaming the latest Handoff Context section to Final Progress and moving the file to done/ in state-machine mode), merges via GitHub CLI, and reports status. Also cleans up stale merged-but-not-removed worktrees from prior sessions on every Claude Code run. Codex V1 uses a merge-only profile that performs no pre-merge plan or worktree mutation. Use when the user says "merge", "merge PR", "merge this", or wants to land the current branch.
Install
npx vskill@latest install hanamizuki/solopreneur/merge-prSKILL.md
Merge PR
Host profiles
Before any other action, check whether CODEX_THREAD_ID is set.
- Unset — Claude Code: run Steps 0–6 unchanged.
- Set — Codex V1: use the merge-only profile. Skip Steps 0 and 3 entirely;
run Steps 1, 2, 4, 5, and 6. Do not clean another worktree, consolidate or move a plan, create a commit, or push before the CI gate. This deliberately omits Claude's plan-state housekeeping so an Autopilot call after Greenlight cannot mutate the reviewed head before merge.
The Codex profile keeps the current worktree and uses GitHub's atomic --match-head-commit precondition. After GitHub reports the PR merged, it may delete the remote feature branch; failure to delete is reported as cleanup debt, never misreported as a failed merge.
Core Design: Why the Current Session's Own Worktree Cannot Be Deleted
When a Claude Code session starts, it locks a primary working directory. After each Bash tool call completes, the harness resets CWD back to that path. If the current session's worktree is deleted mid-session (e.g. via git worktree remove), the next Bash call fails its cd before any command runs — the entire session becomes non-functional.
Solution: leave your own worktree for the next session to clean up. Every /merge-pr run scans all worktrees and removes stale merged ones, except the current session's own worktree. This caps the long-term residue at 1 leftover worktree, which gets cleaned on the next /merge-pr run from any other session.
Flow
Step 0: Scan and clean up stale worktrees from prior sessions (Claude only)
On Codex, skip this step. On Claude Code, regardless of whether there is a new PR to merge, start by cleaning up any worktrees left over from previous sessions whose branches have already been merged. Skip only the current session's own worktree.
Step 1: Confirm the current PR to merge
Determine the branch name from the current working context. If there is no open PR for this branch (e.g. the user only wanted stale-worktree cleanup), stop after Step 0.
Step 2: Pre-merge uncommitted-changes check (only runs in a worktree)
Refuse to proceed if the worktree has any uncommitted changes. The new flow commits everything intentionally, so anything uncommitted here is a mistake that must be surfaced before merging.
Step 3: Consolidate the plan file for this branch (Claude only)
On Codex, skip this step. On Claude Code, resolve the plan file associated with the current branch, rename the latest Handoff Context section to Final Progress, delete older same-branch Handoff Context sections, update the status line, optionally move the file to done/, and commit each change.
Step 3a: Resolve plan file path
Build the list of plan roots — union of $BACKLOG, $DOING, $DONE_DIR, and $PLANS_DIR (whichever are set and exist on disk).
Resolution order (first match wins):
- Plan-Branch marker (primary): search for
*.mdfiles containing
Plan-Branch: <exact branch> in any plan root.
``bash PLAN_FILE="" for root in "$BACKLOG" "$DOING" "$DONE_DIR" "$PLANS_DIR"; do [ -z "$root" ] && continue [ -d "$root" ] || continue match=$(grep -lF "Plan-Branch: ${BRANCH}" "$root"/*.md 2>/dev/null | head -1) if [ -n "$match" ]; then PLAN_FILE="$match" break fi done ``
- Commit-history grep (fallback): only if
PLAN_FILEis still empty.
Find the most recent commit matching the handoff pattern and extract its .md file path.
```bash if [ -z "$PLAN_FILE" ]; then HANDOFF_SHA=$(git log --pretty=format:'%H %s' main..HEAD \
if [ -n "$HANDOFF_SHA" ]; then PLAN_FILE=$(git show --name-only --format='' "$HANDOFF_SHA" \
| grep -E '\.md$' \ |
|---|
| head -1) |
fi fi ```
- No match → skip consolidation. Not every branch has a plan file.
Step 3 still succeeds; consolidation is simply not performed.
Step 3b: Rule-based consolidation
Only runs if PLAN_FILE is set and the file exists on disk.
Changes to make in `PLAN_FILE`:
- Find all
## Handoff Context (<date>, branch: <BRANCH>)sections
(matched by branch name in the heading):
``bash ESC_BRANCH=$(printf '%s' "$BRANCH" | sed 's/[]\.[*^$(){}?+|]/\\&/g') grep -n "^## Handoff Context (.*branch: ${ESC_BRANCH})" "$PLAN_FILE" ``
- Rename the latest matching section to
## Final Progress (merged <MERGE_DATE>, branch: <BRANCH>) where <MERGE_DATE> = $(date +%Y-%m-%d). Do NOT modify any [ ] or [x] checkboxes inside the section.
- Delete older same-branch Handoff Context sections (all but the latest).
"Older" means earlier in the file. Sections from other branches are left untouched.
- Update the top-of-file status line if present: find a line matching
Status: <something> in the first 20 lines and replace it with Status: merged <MERGE_DATE>.
Implementation — use Python to process the file (sed is too fragile for multi-line section deletion). The key invariant: never touch [ ] or [x] checkboxes.
Write the following script to a temp file and run it:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/solopreneur/merge-pr/SKILL.md
Popularity
- Repository stars
- 144
- Repository forks
- 9
- 7-day trend score
- 25
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hanamizuki/solopreneur/merge-pr)