---
name: step-merge
description: Review checklist and merge PR
next_step: steps/step-finish.md
---

# Step: MERGE - Review and Merge PR

## YOUR TASK:

Run through review checklist and merge the pull request with appropriate strategy.

**ULTRA THINK about merge safety.**

---

## EXECUTION SEQUENCE:

### 1-2. Load Config and Display Review Checklist

See [references/merge-pr-context.md](../references/merge-pr-context.md) for:
- Load GitFlow config and PR context
- Load PR state from cache or query provider
- Display review checklist

### 3-4. Check CI and Review Status

See [references/merge-ci-status.md](../references/merge-ci-status.md) for:
- CI status checking (GitHub)
- Review status checking (GitHub)
- User confirmation if CI failing or reviews insufficient

### 5-8. Merge Execution and Verification

See [references/merge-execution.md](../references/merge-execution.md) for:
- Merge strategy determination (squash for features, merge for release/hotfix)
- Execution on GitHub and Azure DevOps
- Merge verification with tracking ref update

### Final Confirmation

Ask user to confirm merge strategy before execution.

### 9. Summary

```
╔══════════════════════════════════════════════════════════════════╗
║                    PR MERGED                                      ║
╠══════════════════════════════════════════════════════════════════╣
║  PR:       #{PR_NUMBER}                                           ║
║  Strategy: {MERGE_STRATEGY}                                       ║
║  Target:   {TARGET_BRANCH}                                        ║
╠══════════════════════════════════════════════════════════════════╣
║  Branch:   {deleted | kept}                                       ║
{if MERGE_BACK}
║  Merge back: {MERGE_BACK} pending                                 ║
{endif}
╠══════════════════════════════════════════════════════════════════╣
║  NEXT: /gitflow finish                                            ║
╚══════════════════════════════════════════════════════════════════╝
```

---

## ERROR HANDLING:

| Error | Solution |
|-------|----------|
| CI failing | Wait for fix or force merge |
| No reviews | Request review or bypass |
| Merge conflicts | Rebase and retry |
| Branch protection | Request admin merge |

---

## SUCCESS CRITERIA:

- Review checklist completed
- CI checks passing (or bypassed)
- PR merged with correct strategy
- Source branch deleted

## NEXT STEP:

Proceed to `/gitflow finish` (automatically or manually).
