claude-mergetool 1.2.0

AI-powered merge conflict resolution using Claude Code
claude-mergetool-1.2.0 is not a library.

claude-mergetool

Have you ever wished that resolving Git merge conflicts could cost you real-world dollars? Now it can!

claude-mergetool implements AI-powered merge conflict resolution using Claude Code. When git or jj hits a merge conflict, claude-mergetool launches Claude to read the three versions of the file, resolve the conflict, and write the result — fully automatically.

It works surprisingly well, although I feel much more comfortable using it in jj where the conflicted files are written to a temporary directory (so the AI doesn't get free write access to my checkout) and I can easily run jj diff to inspect how the conflicts were resolved once it finishes.

[!WARNING]

Note that claude is launched with --permission-mode=acceptEdits to the various conflicted files. With jj, these are in a temporary directory, but with git I'm not sure. There is, as always with AI tools that can touch files on your disk, some risk of unintended changes!

Install

cargo install claude-mergetool
# or
nix profile install nixpkgs#claude-mergetool
nix profile install github:9999years/claude-mergetool

Prerequisites

Claude Code (claude CLI) must be installed and available in PATH.

Setup

You can configure claude-mergetool automatically:

claude-mergetool install

Then, you can use git mergetool -t claude to resolve conflicts with Git or jj resolve --tool claude to resolve conflicts with JJ.

To configure claude-mergetool only for one program or the other, use (e.g.) claude-mergetool install jj.

jj

Add to ~/.config/jj/config.toml:

[merge-tools.claude]
program = "claude-mergetool"
merge-args = ["merge", "$base", "$left", "$right", "-o", "$output", "-p", "$path"]

Then resolve conflicts with:

jj resolve -r REVSET --tool claude

git

Add to ~/.config/git/config (or ~/.gitconfig):

[mergetool "claude"]
    cmd = claude-mergetool merge "$BASE" "$LOCAL" "$REMOTE" -o "$MERGED"
    trustExitCode = true

Then resolve conflicts with:

git mergetool -t claude

Usage

claude-mergetool is normally invoked by git or jj, but you can also run it directly:

claude-mergetool merge base.txt left.txt right.txt -o resolved.txt

CLI reference

Usage: claude-mergetool merge [OPTIONS] <BASE> <LEFT> <RIGHT>

Arguments:
  <BASE>   Base version (common ancestor)
  <LEFT>   Left version (ours / current branch)
  <RIGHT>  Right version (theirs / incoming)

Options:
      --git-merge-driver  Git merge driver mode (writes result to `<left>` path)
  -o, --output <OUTPUT>  Output file path (jj mode)
  -s <ANCESTOR_LABEL>    Ancestor conflict label
  -x <LEFT_LABEL>        Left/ours conflict label [default: ours]
  -y <RIGHT_LABEL>       Right/theirs conflict label [default: theirs]
  -p <FILEPATH>          Original file path [default: "unknown file"]
  -l <MARKER_SIZE>       Conflict marker size
  -h, --help             Print help

How it works

claude-mergetool runs claude in non-interactive mode (--print) with --permission-mode=acceptEdits, so tool calls (Read, Edit, Write) are auto-approved with no user interaction required. Claude's reasoning and tool calls are streamed to stderr as dimmed text so you can follow along. When Claude finishes, the merge continues automatically.