跳到正文
Skillpedia
部署与云(DevOps)16k · #10803

pr-merge

它能做什么

这个技能指导维护者审阅并合并以拉取请求形式提交的贡献。适合希望贡献者保留其署名的项目负责人。

适用场景

  • ✓当你有多个来自外部贡献者的待审阅和待合并的拉取请求时。
  • ✓当某个拉取请求存在合并冲突,并且你希望在不改写贡献者工作的前提下解决冲突时。
  • ✓当你只想合并拉取请求中的一部分,例如选定的几个文件时。

技能链接

https://github.com/HKUDS/OpenHarness/blob/main/.claude/skills/pr-merge/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/OpenHarness/blob/main/.claude/skills/pr-merge/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请查看我们仓库中待处理的拉取请求,合并没有冲突的请求,并保留每位作者的署名。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会列出待处理的拉取请求并分类。对于没有冲突的,它会通过 GitHub 合并,从而保留作者信息;对于较难的,它会在本地合并,并在单独的修改中解决冲突。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

PR Merge — Contributor-First Pull Request Integration

Merge external pull requests while maximizing original author attribution. Core principle: merge first, resolve conflicts after — never rewrite a contributor's work from scratch.

Core Principles

  1. Preserve authorship — use gh pr merge --squash for clean PRs. For manual merges, use --author="Name <email>".
  2. Merge first, fix after — accept the PR's approach even if it differs from local style. Fix conflicts in a separate commit.
  3. Selective merge is OK — exclude files with --exclude when a PR contains features already implemented locally. Document what was excluded.
  4. Never git apply + self-commit — this loses author attribution entirely.

Workflow

1. Triage Open PRs

gh pr list --repo OWNER/REPO --state open \
  --json number,title,author,additions,deletions,mergeable

Classify each PR: merge directly, merge with conflict resolution, selective merge, or close.

2. Merge Clean PRs via GitHub

Prefer gh pr merge — preserves author automatically:

gh pr merge NUMBER --repo OWNER/REPO --squash \
  --subject "feat: description (#NUMBER)"

3. Handle Conflicting PRs Locally

git fetch origin pull/NUMBER/head:pr-NUMBER
git merge pr-NUMBER --no-edit
# Resolve conflicts keeping both sides where possible
git add -A && git commit --no-edit

4. Selective Merge (Skip Some Files)

When a PR contains features already implemented locally:

gh pr diff NUMBER --repo OWNER/REPO | \
  git apply --exclude='path/to/skip.py' --exclude='CHANGELOG.md'
git commit --author="Author Name <author@email>" \
  -m "feat: description (#NUMBER)

Cherry-picked from PR #NUMBER. Excluded: file.py (already implemented)."

5. Close Duplicate/Superseded PRs

gh pr close NUMBER --repo OWNER/REPO \
  --comment "Fixed via PR #OTHER. Thank you for the contribution!"

6. Post-Merge Verification

python -m ruff check src/ tests/    # lint
python -m pytest tests/ -q          # unit tests
git push origin main                # push

Then run harness-eval for end-to-end verification on an unfamiliar codebase.

Attribution Checklist

Before pushing a merged PR:

  • Original author appears in git log (via --author or GitHub squash merge)
  • Commit message references PR number (#NUMBER)
  • If selectively merged, commit body explains exclusions
  • Closed PRs have a comment thanking the contributor
  • Duplicate PRs acknowledge the contributor's investigation

Common Pitfalls

  • git apply + self-commit loses author
  • Rewriting from scratch instead of merging — merge their code, fix style after
  • Force-pushing main after merge — may remove contributor commits
  • Forgetting CHANGELOG conflicts — always exclude and handle manually
  • Not testing after merge — clean merge doesn't mean working code

Additional Resources

Reference Files

  • references/merge-scenarios.md — Detailed examples for each merge scenario (clean, conflicting, selective, duplicate)
常见问题

贡献者还能保留署名吗?

可以。该技能优先使用 GitHub 合并,并在手动合并时设置作者信息,因此署名会被保留。

它会重写贡献者的代码吗?

不会。该技能说明应先接受贡献者的做法,之后在单独的提交中修复任何冲突。

我可以只合并拉取请求中的部分文件吗?

可以。该技能允许选择性合并,跳过已在本地实现的文件,并要求你记录被跳过的内容。

详情

作者的原始描述

This skill should be used when the user asks to "merge a PR", "review and merge pull requests", "integrate external contributions", "handle PR conflicts", "cherry-pick from a PR", or needs to merge GitHub PRs while maximizing contributor attribution.

repo: HKUDS/OpenHarness

热度

GitHub 星标
16k
排名
#10803
许可证
MIT
更新时间
2026/6/3

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

相似技能