Pr merge

From matteocervelli/llms · View interactive version

Pr merge is an AI agent skill from the GitHub repository matteocervelli/llms. Safely merge GitHub pull requests using comprehensive pre-merge validation. Use this skill when the user asks to merge a PR, complete a PR workflow, or check if a PR is ready to merge. Validates CI/CD status, reviews, and conflicts before merging with the appropriate strategy.

How to use this skill

Skill file

PR Merge

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.

When to Use This Skill

Use this skill when the user requests:

Pre-Merge Validation Workflow

Before merging any PR, execute the complete validation workflow to ensure safety and quality.

Step 1: Fetch PR Details

Use mcp__github-mcp__get_pull_request to retrieve:

Required parameters:

Step 2: Check CI/CD Status

Use mcp__github-mcp__get_pull_request_status to verify:

Block merge if:

Step 3: Verify Reviews

Use mcp__github-mcp__get_pull_request_reviews to confirm:

Block merge if:

Step 4: Check for Conflicts

Use mcp__github-mcp__get_pull_request_diff to identify:

Block merge if:

Step 5: Review Changes (Optional)

For additional safety, use mcp__github-mcp__get_pull_request_files to:

Merge Execution

Once all validations pass, execute the merge using mcp__github-mcp__merge_pull_request.

Selecting Merge Method

Choose the appropriate merge method based on project conventions and commit history:

Squash Merge (squash):

Merge Commit (merge):

Rebase Merge (rebase):

Default recommendation: Use squash unless project conventions dictate otherwise.

Merge Parameters

Required:

Optional:

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"

Post-Merge Actions

After successful merge, inform the user:

  1. Confirm merge completion
  2. Show resulting commit SHA
  3. Note which branch was merged
  4. Suggest deleting the head branch if appropriate

Do not automatically delete branches - let the user decide or check repository settings.

Safety Guidelines

Always follow these safety rules:

  1. Never force merge - All checks must pass
  2. Never bypass reviews - Required approvals must exist
  3. Never merge with conflicts - Conflicts must be resolved first
  4. Never merge draft PRs - Must be marked as ready for review
  5. Always inform the user - Provide clear feedback on validation status

Validation Failure Responses

When pre-merge validation fails, provide clear, actionable feedback:

CI/CD Failures:

Review Issues:

Merge Conflicts:

Branch Protection:

Advanced Features

Request Automated Review

Before merging, optionally use mcp__github-mcp__request_copilot_review to:

Update Branch Before Merge

If the base branch has advanced, use mcp__github-mcp__update_pull_request_branch to:

Check Multiple PRs

For workflow automation, can validate multiple PRs in sequence:

  1. Use mcp__github-mcp__list_pull_requests to find open PRs
  2. Filter for PRs ready to merge
  3. Execute validation workflow for each
  4. Present merge candidates to user

Complete Workflow Example

User request: "Merge PR #42"

Execution sequence:

  1. Fetch PR details → Confirm it's open, not draft
  2. Check CI/CD status → All checks passing ✓
  3. Verify reviews → 2 approvals, no requested changes ✓
  4. Check conflicts → No conflicts ✓
  5. Select merge method → Choose squash (clean commit history)
  6. Execute merge → merge_pull_request with squash method
  7. Confirm success → "PR #42 successfully merged with squash merge"

Error Handling

Handle common errors gracefully:

Provide clear error messages and next steps for resolution.

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.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.