pr-merge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePR Merge
PR 合并
Overview
概述
This skill enables safe and comprehensive pull request merging workflows using GitHub MCP tools. It automates the complete pre-merge validation process, checks CI/CD status, verifies reviews, and executes merges with the appropriate merge strategy.
此技能借助GitHub MCP工具实现安全、全面的拉取请求(PR)合并工作流。它自动化完成合并前的完整验证流程,检查CI/CD状态、审核情况,并采用合适的合并策略执行合并。
When to Use This Skill
何时使用此技能
Use this skill when the user requests:
- "Merge PR #123"
- "Can we merge this pull request?"
- "Check if PR is ready to merge"
- "Complete the PR workflow"
- "Merge this feature branch"
- "Is PR #456 ready to be merged?"
当用户提出以下请求时使用此技能:
- "合并PR #123"
- "我们可以合并这个拉取请求吗?"
- "检查PR是否可合并"
- "完成PR工作流"
- "合并此功能分支"
- "PR #456是否可以合并?"
Pre-Merge Validation Workflow
合并前验证工作流
Before merging any PR, execute the complete validation workflow to ensure safety and quality.
在合并任何PR之前,执行完整的验证工作流以确保安全性和质量。
Step 1: Fetch PR Details
步骤1:获取PR详情
Use to retrieve:
mcp__github-mcp__get_pull_request- PR title and description
- Base and head branches
- Draft status
- Current state (open/closed)
Required parameters:
- : Repository owner
owner - : Repository name
repo - : PR number
pullNumber
使用获取以下信息:
mcp__github-mcp__get_pull_request- PR标题和描述
- 基准分支和头部分支
- 草稿状态
- 当前状态(打开/关闭)
必填参数:
- : 仓库所有者
owner - : 仓库名称
repo - : PR编号
pullNumber
Step 2: Check CI/CD Status
步骤2:检查CI/CD状态
Use to verify:
mcp__github-mcp__get_pull_request_status- All required checks are passing
- No failed CI/CD workflows
- Branch protection rules are satisfied
Block merge if:
- Any required checks are failing
- Checks are still pending (inform user to wait)
- Branch protection rules are not met
使用验证:
mcp__github-mcp__get_pull_request_status- 所有必填检查均已通过
- 无失败的CI/CD工作流
- 满足分支保护规则
阻止合并的情况:
- 任何必填检查失败
- 检查仍在进行中(告知用户等待)
- 未满足分支保护规则
Step 3: Verify Reviews
步骤3:验证审核情况
Use to confirm:
mcp__github-mcp__get_pull_request_reviews- Sufficient approved reviews exist
- No requested changes are outstanding
- Review requirements are met per branch protection
Block merge if:
- Required reviews are missing
- Any reviewer has requested changes
- Review dismissals need to be addressed
使用确认:
mcp__github-mcp__get_pull_request_reviews- 存在足够的已批准审核
- 无未处理的修改请求
- 符合分支保护要求的审核条件
阻止合并的情况:
- 缺少必填审核
- 任何审核者提出了修改请求
- 需要处理审核驳回的问题
Step 4: Check for Conflicts
步骤4:检查冲突
Use to identify:
mcp__github-mcp__get_pull_request_diff- Merge conflicts with base branch
- File-level conflicts that need resolution
Block merge if:
- Merge conflicts are present (instruct user to resolve)
- Base branch needs to be updated first
使用识别:
mcp__github-mcp__get_pull_request_diff- 与基准分支的合并冲突
- 需要解决的文件级冲突
阻止合并的情况:
- 存在合并冲突(指导用户解决)
- 基准分支需要先更新
Step 5: Review Changes (Optional)
步骤5:审查变更(可选)
For additional safety, use to:
mcp__github-mcp__get_pull_request_files- Review changed files
- Identify potential issues
- Confirm changes align with PR description
为进一步确保安全,使用:
mcp__github-mcp__get_pull_request_files- 审查变更的文件
- 识别潜在问题
- 确认变更与PR描述一致
Merge Execution
合并执行
Once all validations pass, execute the merge using .
mcp__github-mcp__merge_pull_request所有验证通过后,使用执行合并。
mcp__github-mcp__merge_pull_requestSelecting Merge Method
选择合并方式
Choose the appropriate merge method based on project conventions and commit history:
Squash Merge ():
squash- Use for: Feature branches with messy commit history
- Benefits: Clean, single commit in main branch
- When: Multiple small commits, WIP commits, or iterative development
- Example: PR with 15 commits like "fix typo", "address review", "fix tests"
Merge Commit ():
merge- Use for: Preserving complete commit history
- Benefits: Full audit trail, maintains original commits
- When: Well-structured commits with meaningful messages
- Example: PR with clean, atomic commits following conventional commit style
Rebase Merge ():
rebase- Use for: Linear history without merge commits
- Benefits: Clean, linear git history
- When: Small PRs with few commits
- Example: Single-commit PRs or small bug fixes
Default recommendation: Use unless project conventions dictate otherwise.
squash根据项目约定和提交历史选择合适的合并方式:
压缩合并():
squash- 适用场景:提交历史混乱的功能分支
- 优势:主分支中保留简洁的单个提交
- 时机:包含多个小提交、WIP提交或迭代开发的PR
- 示例:包含15个类似“修复拼写错误”、“处理审核意见”、“修复测试”的提交的PR
合并提交():
merge- 适用场景:保留完整的提交历史
- 优势:完整的审计追踪,保留原始提交
- 时机:提交结构清晰、消息有意义的PR
- 示例:遵循规范提交风格的清晰、原子化提交的PR
变基合并():
rebase- 适用场景:无合并提交的线性历史
- 优势:简洁、线性的Git历史
- 时机:提交数量少的小型PR
- 示例:单提交PR或小型Bug修复
默认推荐: 除非项目有明确约定,否则使用。
squashMerge Parameters
合并参数
Required:
- : Repository owner
owner - : Repository name
repo - : PR number
pullNumber
Optional:
- : "merge", "squash", or "rebase" (default: merge)
merge_method - : Custom commit title for squash/merge
commit_title - : Additional commit message details
commit_message
必填:
- : 仓库所有者
owner - : 仓库名称
repo - : PR编号
pullNumber
可选:
- : "merge", "squash", or "rebase"(默认:merge)
merge_method - : 压缩/合并的自定义提交标题
commit_title - : 提交消息的额外细节
commit_message
Example Merge Execution
合并执行示例
Use mcp__github-mcp__merge_pull_request with:
- owner: "user"
- repo: "project"
- pullNumber: 123
- merge_method: "squash"
- commit_title: "feat: add user authentication system"使用mcp__github-mcp__merge_pull_request,参数如下:
- owner: "user"
- repo: "project"
- pullNumber: 123
- merge_method: "squash"
- commit_title: "feat: add user authentication system"Post-Merge Actions
合并后操作
After successful merge, inform the user:
- Confirm merge completion
- Show resulting commit SHA
- Note which branch was merged
- Suggest deleting the head branch if appropriate
Do not automatically delete branches - let the user decide or check repository settings.
合并成功后,告知用户:
- 确认合并完成
- 显示生成的提交SHA
- 记录合并的分支
- 如有必要,建议删除头部分支
请勿自动删除分支 - 让用户决定或检查仓库设置。
Safety Guidelines
安全准则
Always follow these safety rules:
- Never force merge - All checks must pass
- Never bypass reviews - Required approvals must exist
- Never merge with conflicts - Conflicts must be resolved first
- Never merge draft PRs - Must be marked as ready for review
- Always inform the user - Provide clear feedback on validation status
请始终遵循以下安全规则:
- 切勿强制合并 - 所有检查必须通过
- 切勿绕过审核 - 必须存在必填的批准
- 切勿合并存在冲突的PR - 冲突必须先解决
- 切勿合并草稿PR - 必须标记为可审核状态
- 始终告知用户 - 提供清晰的验证状态反馈
Validation Failure Responses
验证失败响应
When pre-merge validation fails, provide clear, actionable feedback:
CI/CD Failures:
- List which checks are failing
- Suggest using with
mcp__github-mcp__get_job_logsto diagnosefailed_only=true - Recommend reviewing workflow files
Review Issues:
- List missing required reviews
- Identify reviewers who requested changes
- Suggest addressing review comments first
Merge Conflicts:
- Identify conflicting files
- Recommend updating base branch with
mcp__github-mcp__update_pull_request_branch - Suggest resolving conflicts locally if needed
Branch Protection:
- List unmet protection rules
- Explain which requirements are blocking
- Suggest how to satisfy requirements
当合并前验证失败时,提供清晰、可操作的反馈:
CI/CD失败:
- 列出失败的检查项
- 建议使用并设置
mcp__github-mcp__get_job_logs来诊断问题failed_only=true - 建议查看工作流文件
审核问题:
- 列出缺失的必填审核
- 识别提出修改请求的审核者
- 建议先处理审核意见
合并冲突:
- 识别冲突文件
- 建议使用更新基准分支
mcp__github-mcp__update_pull_request_branch - 必要时建议在本地解决冲突
分支保护问题:
- 列出未满足的保护规则
- 说明哪些要求阻止了合并
- 建议如何满足要求
Advanced Features
高级功能
Request Automated Review
请求自动审核
Before merging, optionally use to:
mcp__github-mcp__request_copilot_review- Get AI-powered code review
- Identify potential issues
- Supplement human reviews
合并前,可选择使用:
mcp__github-mcp__request_copilot_review- 获取AI驱动的代码审核
- 识别潜在问题
- 补充人工审核
Update Branch Before Merge
合并前更新分支
If the base branch has advanced, use to:
mcp__github-mcp__update_pull_request_branch- Sync PR branch with latest base
- Trigger CI/CD re-runs
- Ensure up-to-date merge
如果基准分支已更新,使用:
mcp__github-mcp__update_pull_request_branch- 同步PR分支与最新的基准分支
- 触发CI/CD重新运行
- 确保合并是基于最新版本
Check Multiple PRs
检查多个PR
For workflow automation, can validate multiple PRs in sequence:
- Use to find open PRs
mcp__github-mcp__list_pull_requests - Filter for PRs ready to merge
- Execute validation workflow for each
- Present merge candidates to user
对于工作流自动化,可按顺序验证多个PR:
- 使用查找打开的PR
mcp__github-mcp__list_pull_requests - 筛选出可合并的PR
- 为每个PR执行验证工作流
- 向用户展示可合并的候选PR
Complete Workflow Example
完整工作流示例
User request: "Merge PR #42"
Execution sequence:
- Fetch PR details → Confirm it's open, not draft
- Check CI/CD status → All checks passing ✓
- Verify reviews → 2 approvals, no requested changes ✓
- Check conflicts → No conflicts ✓
- Select merge method → Choose squash (clean commit history)
- Execute merge → with squash method
merge_pull_request - Confirm success → "PR #42 successfully merged with squash merge"
用户请求: "合并PR #42"
执行顺序:
- 获取PR详情 → 确认PR已打开,不是草稿 ✓
- 检查CI/CD状态 → 所有检查通过 ✓
- 验证审核情况 → 2个批准,无修改请求 ✓
- 检查冲突 → 无冲突 ✓
- 选择合并方式 → 选择压缩合并(简洁提交历史)
- 执行合并 → 使用压缩方式调用
merge_pull_request - 确认成功 → "PR #42已通过压缩合并成功合并"
Error Handling
错误处理
Handle common errors gracefully:
- 404 Not Found: PR doesn't exist, verify PR number
- 405 Method Not Allowed: PR already merged or closed
- 409 Conflict: Merge conflict exists, need resolution
- 422 Validation Failed: Branch protection rules not met
Provide clear error messages and next steps for resolution.
优雅处理常见错误:
- 404 Not Found: PR不存在,请验证PR编号
- 405 Method Not Allowed: PR已合并或关闭
- 409 Conflict: 存在合并冲突,需要解决
- 422 Validation Failed: 未满足分支保护规则
提供清晰的错误信息和解决下一步建议。
Resources
资源
This skill uses GitHub MCP tools exclusively and does not require additional scripts, references, or assets. All functionality is provided through the MCP integration.
此技能仅使用GitHub MCP工具,无需额外脚本、参考或资源。所有功能均通过MCP集成提供。