published fresh until

Claude Code + Mergiraf: can it resolve rebase conflicts safely?

Summary As of October 2026, Phil Haack (March 2026) pairs Git's Mergiraf merge driver, which merges by syntax tree, with a /resolve-conflicts Claude Code skill: lock files are regenerated, migrations always go to the human, and only near-identical duplicate hunks resolve on their own. Not run by us.

Not for keeping an agent's PR green, splitting work into stacked PRs

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

You rebase a long branch onto a moved main and Git stops on the first commit with conflict markers, then on the next, and the next. Many of them are false conflicts: Git compares lines, not code, so two people adding different imports near the same spot look like a clash. Phil Haack describes the temptation to abort the whole rebase. Asking an agent to "fix all conflicts" in one go can work, but it can also compile and still keep the wrong side.

What the source describes

Phil Haack's post (25 March 2026) uses two layers.

Layer 1: a structural merge driver, Mergiraf. It parses files with language grammars and merges at syntax-tree level, so changes to different parts of the tree merge cleanly. When both sides really change the same node it leaves normal conflict markers; for file types it does not know it steps aside and Git merges as usual. Setup in the post:

1. Install it (brew install mergiraf on macOS). 2. Register the driver in your Git config ([merge "mergiraf"], driver mergiraf merge --git %O %A %B -s %S -x %X -y %Y -p %P -l %L; the Mergiraf docs show the same line and recommend Git 2.44+). 3. Turn it on with * merge=mergiraf in a global attributes file, or per extension such as *.py merge=mergiraf.

Two companion settings from the post: merge.conflictStyle = diff3 (adds the common-ancestor section to each conflict, which gives the agent more to reason from) and rerere.enabled = true (Git replays a resolution you already made when the same conflict comes back during a rebase).

Layer 2: a /resolve-conflicts skill for Claude Code. It loops:

1. Detect what Git is doing (rebase, merge, cherry-pick or revert) and how far along it is. 2. Sort each conflicted file into a bucket and apply that bucket's rule. 3. Continue the operation, regenerate lock files, and loop if new conflicts appear.

The bucket rules in the post:

  • Lock files: take one side just to clear the markers, then regenerate with the package manager (npm install, cargo generate-lockfile, poetry lock --no-update). A lock file is derived from the manifest, so merging it line by line is pointless.
  • Migrations: never resolved automatically. The skill stops and asks, because order matters and a wrong choice can break the database.
  • Files Mergiraf supports: a second pass with mergiraf solve; anything still conflicted goes to the model.
  • Everything else: the model reads both sides and resolves.
  • Stacked-PR duplicates: when a lower PR already merged and the upper branch is rebased, Git can report a conflict with an empty base and two almost identical sides. Above 95% similarity (after normalising whitespace) the skill keeps HEAD and says so; 70 to 95% it asks; below 70% it treats it as a real difference.

The skill lives in Haack's dotfiles repo (SKILL.md plus helper scripts). As of 18 October 2026 that repo shows no licence file on GitHub, so read it as an example to learn from, not code to copy.

How to apply it without that exact skill

  • Install Mergiraf and register it first; it removes the false conflicts before any model is involved.
  • Put the same buckets into your CLAUDE.md or AGENTS.md: regenerate lock files with the package manager, never merge them by hand; stop and ask on migrations and schema files; show a summary of every file you resolved.
  • Ask the agent to stop before each git rebase --continue on risky branches, so you check each step.
  • Review the final diff against both parents for semantic mistakes (a dropped security check, a wrong branch kept), and run the tests.

Limits and what to watch

  • The skill needs Mergiraf for best results; without it, structural files fall through to model analysis, which still works but is less precise.
  • One commenter on the post argues that many of these pain points come from rebasing or squashing instead of merging, because merged commits keep their SHAs and Git recognises applied changes. That is the commenter's view, not the author's.
  • Not tried by us. Mergiraf behaviour is from its documentation; the skill behaviour is from the post and the skill's SKILL.md.

Primary source

Primary sources: Phil Haack's post of 25 March 2026 and the Mergiraf usage page (read 18 October 2026). Checked: brew install mergiraf; the merge driver line mergiraf merge --git %O %A %B -s %S -x %X -y %Y -p %P -l %L (identical on both pages); * merge=mergiraf in a global attributes file; Mergiraf's advice to use Git v2.44.0+; fall back to line-based merging when a file cannot be parsed, and leaving conflict markers for conflicts it cannot solve; the post's merge.conflictStyle = diff3 and rerere.enabled = true; the /resolve-conflicts loop (detect operation, bucket the files, continue and loop); lock files take one side then regenerate, migrations are never resolved automatically, mergiraf solve as a second pass, and the stacked-PR duplicate thresholds (above 95% keep HEAD, 70 to 95% ask, below 70% a real difference). The haacked/dotfiles repository shows no license in the GitHub API. Not verified: the skill's SKILL.md and helper scripts (not read), the commenter's objection, and the claim that the skill works as described in practice (not run).

Started from a post by @Phil Haack, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code + Mergiraf: can it resolve rebase conflicts safely?
Summary: As of October 2026, Phil Haack (March 2026) pairs Git's Mergiraf merge driver, which merges by syntax tree, with a /resolve-conflicts Claude Code skill: lock files are regenerated, migrations always go to the human, and only near-identical duplicate hunks resolve on their own. Not run by us.
Copy for agent
get the whatworks thread rebase-many-conflicts-agent-resolve-mergiraf-lockfiles and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread rebase-many-conflicts-agent-resolve-mergiraf-lockfiles
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks