# Pre Merge Conflict Predictor

> Before opening a PR, predict potential merge conflicts by checking if your changed files overlap with other open PRs or branches

- Skill: `ritesh31/pre-merge-conflict-predictor` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add ritesh31/pre-merge-conflict-predictor`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ritesh31/pre-merge-conflict-predictor/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ritesh31 (https://skillmd.com/u/ritesh31)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/ritesh31/pre-merge-conflict-predictor

---


# Pre-Merge Conflict Predictor

## Purpose
Detect potential merge conflicts BEFORE a PR is opened, while they are 
still easy to resolve.

## When to use
- Before running `gh pr create`
- After finishing a feature branch and before pushing
- When you suspect overlap with a teammate's work

## Steps Claude should follow

### 1. Run the detection script
```bash
bash "${CLAUDE_PLUGIN_ROOT}/skills/pre-merge-conflict-predictor/check-conflicts.sh" main
```
Capture full output for analysis.

Only open PRs whose base branch matches the one passed in (`main` above) are
checked. Draft PRs are skipped by default — set `INCLUDE_DRAFTS=1` as an env
var before the command to include them.

The script picks up committed, staged, unstaged, and untracked changes on
your branch — no commit is required before running it, so it can be used
iteratively while you're still working.

### 2. Analyze each overlap — determine REAL risk vs safe overlap

Not all file overlaps are real conflicts. Classify each one:

**HIGH RISK (🔴)** — same function/class modified in both branches
**MEDIUM RISK (🟡)** — same file, different sections
**LOW RISK (🟢)** — same file but only imports/comments/formatting touched
**SAFE (✅)** — file renamed or only one side touched it meaningfully

To determine risk level, for each overlapping file run:
```bash
# See what YOUR branch changed in that file
git diff main...HEAD -- <filename>

# See what the OTHER PR changed in that file  
gh pr diff <PR_NUMBER> -- <filename>
```
Then compare the diffs line by line.

### 3. Generate conflict report

Format the output exactly like this:

---
## 🔍 Pre-Merge Conflict Report
**Branch:** `your-branch-name`
**Base:** `main`
**Checked at:** [timestamp]

### Summary
| PR | Author | Risk | Overlapping Files |
|----|--------|------|-------------------|
| #12 | @alice | 🔴 HIGH | src/auth/login.ts |
| #15 | @bob | 🟡 MEDIUM | src/utils/helpers.ts |

### Detail

#### PR #12 — [title] by @alice
**Risk: 🔴 HIGH**
- `src/auth/login.ts` — Both branches modify the `validateToken()` 
   function. Line 45-67 in yours, line 52-71 in theirs. 
   **Likely hard conflict.**

**Suggested action:**
→ Talk to @alice before merging. Consider rebasing your branch 
  on top of PR #12 first, or splitting your work.

#### PR #15 — [title] by @bob  
**Risk: 🟡 MEDIUM**
- `src/utils/helpers.ts` — You added a new function at line 89. 
  Bob modified the `formatDate()` function at line 23. 
  **Likely auto-mergeable but verify.**

**Suggested action:**
→ Low urgency. Monitor for when PR #15 merges, then rebase.
---

### 4. Final recommendation
End with one of:
- ✅ SAFE TO OPEN PR — no meaningful overlaps found
- ⚠️ OPEN PR BUT COORDINATE — medium risks exist, flag in PR description
- 🚫 RESOLVE FIRST — high-risk overlaps, talk to teammates before opening PR

Include names of teammates to coordinate with if relevant.
