AgentSkillsCN

lazy-merge

在不推送或关闭Pull Request的前提下,于本地拉取并合并GitHub PR,以进行测试。在被要求在本地合并PR、测试性合并Pull Request、检出并合并PR以进行本地测试,或把PR拉取到本地分支时使用。支持PR URL、PR编号(#14、14),或gh引用。但绝不向GitHub推送代码,也绝不会关闭PR。

SKILL.md
--- frontmatter
name: lazy-merge
description: Fetch and merge a GitHub PR locally for testing without pushing or closing the PR. Use when asked to locally merge a PR, test-merge a pull request, checkout and merge a PR for local testing, or pull a PR into a local branch. Accepts PR URLs, numbers (#14, 14), or gh references. Does NOT push to GitHub or close PRs.

Lazy Merge — Local Test Merge Only

LOCAL MERGES ONLY — Does NOT push to GitHub or close PRs.

Input

Accepts: PR URL, #14, 14, or gh pr 14. If none provided, list PRs with gh pr list --limit 30.

Preconditions

bash
git rev-parse --is-inside-work-tree
git remote -v
gh auth status
gh repo view --json name,owner

Verify ownership before proceeding. If not owned by user/org, ask how to proceed.

PR Inspection

bash
gh pr view <number> --json number,title,headRefName,baseRefName,mergeable,state,isDraft,url

Validate:

  • PR is open (not closed)
  • PR is not a draft
  • No merge conflicts (mergeable != "CONFLICTING")

If blocking issues, warn and ask for confirmation.

Merge (LOCAL ONLY)

bash
# Fetch PR branch
gh pr checkout <number>

# Switch to base branch
git checkout <base-branch>

# Merge locally (squash or regular)
git merge --squash <pr-branch>
git commit -m "Local test merge of PR #<number>: <title>"

# OR regular merge:
git merge <pr-branch> --no-ff -m "Local test merge of PR #<number>: <title>"

CRITICAL

  • DO NOT run git push
  • DO NOT run gh pr merge
  • This is LOCAL ONLY for testing

Undo

bash
git reset --hard origin/<base-branch>