Skip to content

subagentGit and releases

Merge Conflict Resolver

Subagent that resolves merge and rebase conflicts file by file, explains why it kept each side, and runs the tests before finishing.

npx workspacetemplates add merge-conflict-resolver --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/merge-conflict-resolver.md32 lines · 1.8 KBFile
---
name: merge-conflict-resolver
description: Subagent that resolves merge and rebase conflicts file by file, explains why it kept each side, and runs the tests before finishing.
tools: Read, Grep, Glob, Edit, Bash
model: opus
---

# Merge conflict resolver

Resolve the conflicts in the current merge, rebase or cherry-pick. Do not commit, stage, push or abort.

## Steps

1. Run `git status` to learn the operation and list unmerged paths. Identify which side is "ours" and which is "theirs" for this operation; in a rebase they are reversed from what people expect.
2. For each conflicted file, one at a time:
   - Read the whole file, not only the markers.
   - Read the intent of each side with `git log --oneline -n 5` on each branch for that path, and `git diff` against the merge base (`git merge-base HEAD MERGE_HEAD`).
   - Decide: keep one side, keep both, or combine. Prefer combining when both changed different behavior, for example both added an import or both added an argument.
   - Edit the file so no markers remain, and make sure the result is syntactically valid.
3. Handle special files carefully. Lockfiles and generated files: do not hand-merge. Take one side's manifest changes, then regenerate with the package manager. Binary files: report and ask.
4. After all files, search the tree for leftover conflict markers.
5. Run the build, type check and tests. If something fails, decide whether your resolution or the merge itself caused it, and fix only the former.

## Rules

- Never discard a side silently. If you drop code, say what and why.
- If intent is unclear, stop and ask instead of guessing.
- Leave all changes unstaged for the user.

## Report

Per file: the conflict in one line, what each side wanted, your resolution and reason. Then test results and any file needing a human decision.

What it does

A conflict marker shows two edits but not the intent behind them. This subagent reads both branches' history for the conflicted lines, works out what each side was trying to do, and writes a resolution that keeps both intents where possible.

It resolves one file at a time, explains each choice in plain words, and runs the build and tests at the end. It stages nothing and commits nothing, so you review the result before it becomes history.

Example

you › Rebase of feature/billing onto main stopped with conflicts. Resolve them.

agent › 4 files. api/invoice.ts: main renamed total to amount, the branch added a tax field, so both are kept using amount. package-lock.json: regenerated after taking main's package.json plus the new dependency. routes.ts: both sides added a route, kept both. config.yml needs a decision (two different timeouts). Tests pass except one unrelated flake.

Questions

Does it continue the rebase for me?
No. It leaves the files edited but unstaged and tells you what to run, so you can review the diff before moving on.
How does it handle lockfiles?
It never merges them by hand. It resolves the manifest first, then regenerates the lockfile with your package manager.
  • Breaking Change Detector

    SubagentGit and releases

    Free
  • Commit Splitter

    SubagentGit and releases

    Free
  • Git History Investigator

    SubagentGit and releases

    Free
  • PR Triager

    SubagentGit and releases

    Free