mcpField

Merge Conflict Resolver

FeaturedOn demand

About Merge Conflict Resolver

This loop rebases the current branch onto origin/main and deals with any conflicts that appear. Each round updates the branch and then runs npm test to verify the result. It is started manually, runs at most 8 rounds and supports Cursor and Claude Code.

Key features

  1. 01Fetches before rebasing, so work lands on the latest origin/main
  2. 02Verifies the rebased code with npm test
  3. 03Capped at 8 rounds to stop repeated failures
  4. 04Supports Cursor and Claude Code

Use cases

  1. 01A feature branch has fallen behind main and needs the latest changes
  2. 02Clearing conflicts with the trunk before a merge
  3. 03Confirming tests still pass after a rebase
Goal
The branch is rebased on main with no conflicts and the tests pass.
Exit when
Stop when the rebase completes and npm test exits 0, or after 8 rounds.
Between iterations run
npm test

Launch prompt

Paste into Cursor / Claude Code. The agent repeats the steps below until the exit condition is met.

prompt.md
Start the "Merge Conflict Resolver" loop.
Goal: The branch is rebased on main with no conflicts and the tests pass.
Max iterations: 8.
Step 1: Update the branch — Fetch from the remote and rebase the current branch onto origin/main. If conflicts appear, inspect each conflicted file, keep the intended changes from both sides and continue the rebase. `git fetch origin && git rebase origin/main`
Step 2: Run the tests — After the rebase finishes, run npm test. An exit code of 0 ends the loop; otherwise the failures show whether a conflict was resolved wrongly or something else broke. `npm test`
Step 3: Fix and retry — Edit code to address the failing tests or unresolved conflicts, then begin the next round.
Between iterations run: `npm test`
Exit when: Stop when the rebase completes and npm test exits 0, or after 8 rounds.

Steps

Each round runs in order; if the exit condition isn’t met, another round starts, up to 8.

01
Update the branch

Fetch from the remote and rebase the current branch onto origin/main. If conflicts appear, inspect each conflicted file, keep the intended changes from both sides and continue the rebase.

$git fetch origin && git rebase origin/main
02
Run the tests

After the rebase finishes, run npm test. An exit code of 0 ends the loop; otherwise the failures show whether a conflict was resolved wrongly or something else broke.

$npm test
03
Fix and retry

Edit code to address the failing tests or unresolved conflicts, then begin the next round.

Not met → next roundExits when met

Supported agents

Coding agents that can run this loop directly.

Cursor
Claude Code

Comments

Markdown supported