agentleFS
TermiX-officialTermiX-official/cryptoclaw/.agents/skills/merge-pr/SKILL.md

merge-pr

Skill100 starsChanged 9 months agoMITView on GitHub

Merge a GitHub PR via squash after /preparepr. Use when asked to merge a ready PR. Do not push to main or modify code. Ensure the PR ends in MERGED state and clean up worktrees after success.

  • Commits and pushes

We split this skill into the rules it gives an agent

24 rules. 0 are common, 14 are distinctive, and 10 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 14

    Distinctive

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Ask for PR number or URL.

    line 14
  2. Distinctive:

    If missing, auto-detect from conversation.

    line 15
  3. Very specific:

    Use gh pr merge --squash as the only path to main.

    line 20
  4. Distinctive:

    Do not run git push at all during merge.

    line 21
  5. Distinctive:

    Do not run gateway stop commands.

    line 22
  6. Distinctive:

    If delegating, require the delegate to run commands and capture outputs.

    line 27
  7. Very specific:

    If you see "fatal: not a git repository", you are in the wrong directory.

    line 31
  8. Very specific:

    Read .local/review.md and .local/prep.md in the worktree.

    line 32
  9. Very specific:

    Ensure PR state is MERGED, never CLOSED.

    line 39
  10. Distinctive:

    Run cleanup only after merge success.

    line 41
  11. Distinctive:

    Create a checklist of all merge steps, print it, then continue and execute the commands.

    line 45
  12. Distinctive:

    Use an isolated worktree for all merge work.

    line 49
  13. Distinctive:

    Run all commands inside the worktree directory.

    line 59
  14. Distinctive:

    Stop if any are true:

    line 101
  15. Very specific:

    If anything is failing or behind, stop and say to run /preparepr.

    line 117
  16. Very specific:

    If checks are still running, use --auto to queue the merge.

    line 121
  17. Very specific:

    If merge fails, report the error and stop.

    line 135
  18. Very specific:

    If the PR needs changes beyond what /preparepr already did, stop and say to run /preparepr again.

    line 136
  19. Distinctive:

    Use a literal multiline string or heredoc for newlines.

    line 147
  20. Distinctive:

    Verify PR state is MERGED

    line 159
  21. Very specific:

    Run cleanup only if step 6 returned MERGED.

    line 167
  22. Distinctive:

    Do not close PRs.

    line 181
  23. Very specific:

    Never push to main. Use gh pr merge --squash only.

    line 184
  24. Distinctive:

    Do not run git push at all in this command.

    line 185

“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Merge PR

Overview

Merge a prepared PR via gh pr merge --squash and clean up the worktree after success.

Inputs

  • Ask for PR number or URL.
  • If missing, auto-detect from conversation.
  • If ambiguous, ask.

Safety

  • Use gh pr merge --squash as the only path to main.
  • Do not run git push at all during merge.
  • Do not run gateway stop commands. Do not kill processes. Do not touch port 18792.

Execution Rule

  • Execute the workflow. Do not stop after printing the TODO checklist.
  • If delegating, require the delegate to run commands and capture outputs.

Known Footguns

  • If you see "fatal: not a git repository", you are in the wrong directory. Use ~/Development/openclaw, not ~/openclaw.
  • Read .local/review.md and .local/prep.md in the worktree. Do not skip.
  • Clean up the real worktree directory .worktrees/pr-<PR> only after a successful merge.
  • Expect cleanup to remove .local/ artifacts.

Completion Criteria

  • Ensure gh pr merge succeeds.
  • Ensure PR state is MERGED, never CLOSED.
  • Record the merge SHA.
  • Run cleanup only after merge success.

First: Create a TODO Checklist

Create a checklist of all merge steps, print it, then continue and execute the commands.

Setup: Use a Worktree

Use an isolated worktree for all merge work.

cd ~/Development/openclaw
# Sanity: confirm you are in the repo
git rev-parse --show-toplevel

WORKTREE_DIR=".worktrees/pr-<PR>"

Run all commands inside the worktree directory.

Load Local Artifacts (Mandatory)

Expect these files from earlier steps:

  • .local/review.md from /reviewpr
  • .local/prep.md from /preparepr
ls -la .local || true

if [ -f .local/review.md ]; then
  echo "Found .local/review.md"
  sed -n '1,120p' .local/review.md
else
  echo "Missing .local/review.md. Stop and run /reviewpr, then /preparepr."
  exit 1
fi

if [ -f .local/prep.md ]; then
  echo "Found .local/prep.md"
  sed -n '1,120p' .local/prep.md
else
  echo "Missing .local/prep.md. Stop and run /preparepr first."
  exit 1
fi

Steps

  1. Identify PR meta
gh pr view <PR> --json number,title,state,isDraft,author,headRefName,baseRefName,headRepository,body --jq '{number,title,state,isDraft,author:.author.login,head:.headRefName,base:.baseRefName,headRepo:.headRepository.nameWithOwner,body}'
contrib=$(gh pr view <PR> --json author --jq .author.login)
head=$(gh pr view <PR> --json headRefName --jq .headRefName)
head_repo_url=$(gh pr view <PR> --json headRepository --jq .headRepository.url)
  1. Run sanity checks

Stop if any are true:

  • PR is a draft.
  • Required checks are failing.
  • Branch is behind main.
# Checks
gh pr checks <PR>

# Check behind main
git fetch origin main
git fetch origin pull/<PR>/head:pr-<PR>
git merge-base --is-ancestor origin/main pr-<PR> || echo "PR branch is behind main, run /preparepr"

If anything is failing or behind, stop and say to run /preparepr.

  1. Merge PR and delete branch

If checks are still running, use --auto to queue the merge.

# Check status first
check_status=$(gh pr checks <PR> 2>&1)
if echo "$check_status" | grep -q "pending\|queued"; then
  echo "Checks still running, using --auto to queue merge"
  gh pr merge <PR> --squash --delete-branch --auto
  echo "Merge queued. Monitor with: gh pr checks <PR> --watch"
else
  gh pr merge <PR> --squash --delete-branch
fi

If merge fails, report the error and stop. Do not retry in a loop. If the PR needs changes beyond what /preparepr already did, stop and say to run /preparepr again.

  1. Get merge SHA
merge_sha=$(gh pr view <PR> --json mergeCommit --jq '.mergeCommit.oid')
echo "merge_sha=$merge_sha"
  1. Optional comment

Use a literal multiline string or heredoc for newlines.

gh pr comment <PR> -F - <<'EOF'
Merged via squash.

- Merge commit: $merge_sha

Thanks @$contrib!
EOF
  1. Verify PR state is MERGED
gh pr view <PR> --json state --jq .state
  1. Clean up worktree only on success

Run cleanup only if step 6 returned MERGED.

cd ~/Development/openclaw

git worktree remove ".worktrees/pr-<PR>" --force

git branch -D temp/pr-<PR> 2>/dev/null || true
git branch -D pr-<PR> 2>/dev/null || true

Guardrails

  • Worktree only.
  • Do not close PRs.
  • End in MERGED state.
  • Clean up only after merge success.
  • Never push to main. Use gh pr merge --squash only.
  • Do not run git push at all in this command.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.