Skip to content
Back to skills

Gh Batch Merge By Labels

ASecurity

Batch merge multiple PRs by label (e.g., all 'ready-to-merge' PRs). Use when you have multiple approved PRs to merge.

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
documentationgobashgit

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill gh-batch-merge-by-labels --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gh Batch Merge By Labels?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Gh Batch Merge By Labels
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-gh-batch-merge-by-labels/badge)](https://www.skillsdirectory.com/skills/majiayu000-gh-batch-merge-by-labels)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: gh-batch-merge-by-labels
description: "Batch merge multiple PRs by label (e.g., all 'ready-to-merge' PRs). Use when you have multiple approved PRs to merge."
category: github
agent: pr-cleanup-specialist
---

# Batch Merge PRs by Label

Merge multiple PRs at once based on label matching.

## When to Use

- Multiple PRs are ready for merge with same status label
- Automating merge of dependent chain of PRs
- Merging all "ready-to-merge" or "approved" PRs
- Batch processing end-of-sprint or release merges
- Reducing manual merge overhead

## Quick Reference

```bash
# List PRs with specific label
gh pr list --label "ready-to-merge" --state open

# Merge single PR
gh pr merge <pr> --squash --delete-branch

# Get PR numbers for batch merge
gh pr list --label "ready-to-merge" --json number --jq '.[].number'

# Merge all PRs with label (requires loop)
for pr in $(gh pr list --label "ready-to-merge" --json number --jq '.[].number'); do
  gh pr merge "$pr" --squash --delete-branch
done
```

## Workflow

1. **Query PRs**: Find all PRs with target label
2. **Verify each**: Check CI status and approvals for each PR
3. **Check dependencies**: Ensure no conflicts between PRs to merge
4. **Sort by order**: Merge in dependency order if applicable
5. **Execute merges**: Merge each PR in sequence
6. **Verify success**: Confirm all PRs merged successfully
7. **Report results**: Summary of merged PRs

## Merge Options

**Squash Merge** (recommended):

- Combines all commits into single commit
- Clean git history
- `--squash` flag enables this

**Create Merge Commit**:

- Preserves all commits
- Clear merge history
- Default behavior without `--squash`

**Rebase and Merge**:

- Linear history
- `--rebase` flag enables this
- Good for feature branches

## Safety Checks

Before batch merging:

1. **CI Status**: All checks passing
2. **Approvals**: Required number of approvals met
3. **Conflicts**: No merge conflicts detected
4. **Dependencies**: No blocked dependencies
5. **Protected rules**: All branch protection rules satisfied

## Output Format

Report batch merge results with:

1. **Total PRs** - Count of PRs to merge
2. **Merge Summary** - PR number, title, status
3. **Success Count** - Number successfully merged
4. **Failed Count** - Number that failed to merge
5. **Errors** - Why any PRs failed

## Error Handling

| Problem | Solution |
|---------|----------|
| CI failing | Skip that PR, check analyze-ci-failure-logs |
| Merge conflict | Resolve manually, cannot batch merge |
| No permissions | Check gh auth status and repo access |
| Branch protection | Verify all required rules met |
| Network error | Retry with exponential backoff |

## References

- See gh-review-pr for PR review checklist
- See verify-pr-ready skill for pre-merge validation
- See CLAUDE.md for PR linking requirements

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.