| name | conflicts-resolve |
| description | Resolve git merge conflicts by semantically merging both sides of each conflict. Use when the user has merge conflicts, asks to resolve conflicts, or is stuck in a merge/rebase with conflict markers. |
Resolve Merge Conflicts
Resolve git merge conflicts by semantically merging both sides. Do every step yourself, end to end.
Arguments
Optional target branch name. Defaults to the repo's default branch (main/master/develop).
Step 1 — Validate
git rev-parse --git-dir > /dev/null 2>&1 || { echo "Error: not a git repository"; exit 1; }
If no conflicts exist (git diff --name-only --diff-filter=U is empty), report "No conflicts found" and stop.
Step 2 — Determine target branch
Use the argument if provided. Otherwise detect:
git remote show origin 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}'
Fallback order if that fails: main → master → develop → first remote branch.
Step 3 — Understand the conflict context
git branch --show-current
git diff --name-only --diff-filter=U
git log --oneline -10 HEAD
git log --oneline -10 <target-branch>
git merge-base HEAD <target-branch>
Step 4 — Resolve each conflicted file
For every file in git diff --name-only --diff-filter=U:
- Read the full file.
- For each
<<<<<<< … ======= … >>>>>>> block, understand what both sides do and produce the correct semantic merge — do not mechanically pick one side.
- When intent is genuinely ambiguous, keep content from both sides and add a
// TODO: verify merge comment on the line above with a one-sentence explanation.
- Write the fully resolved file (zero conflict markers remaining).
- Stage it:
git add <file>.
Step 5 — Verify
git diff --name-only --diff-filter=U
Must return empty. If not, resolve the remaining files and repeat.
Step 6 — Report
Print:
- Each resolved file with a one-line summary of what was chosen
- Any
// TODO: verify merge locations that need human review
- Suggested next command (
git commit or git rebase --continue)
Rules
- Never commit, never push, never delete any branch
- Never drop code silently — ambiguous blocks get a TODO comment, not a silent removal
- If there are uncommitted non-conflict changes in the tree, warn but continue