Merge conflict resolver

Resolves git merge and rebase conflicts by reading the intent of both sides and their commits, never blindly taking ours or theirs, then rebuilding and testing, and asking the user when intents truly clash. Use when a merge or rebase stops on conflicts.

Git & PRsPack: Git Workflow94 linesmerge-conflict-resolver

Install

Run one command — it saves SKILL.md into your agent's skills folder. Restart the agent and the skill is picked up automatically.

Claude Code — macOS, Linux
mkdir -p ~/.claude/skills/merge-conflict-resolver && curl -fsSL https://anymodel.org/en/skills/git-workflow/merge-conflict-resolver/SKILL.md -o ~/.claude/skills/merge-conflict-resolver/SKILL.md
Codex, Cursor — macOS, Linux
mkdir -p ~/.agents/skills/merge-conflict-resolver && curl -fsSL https://anymodel.org/en/skills/git-workflow/merge-conflict-resolver/SKILL.md -o ~/.agents/skills/merge-conflict-resolver/SKILL.md
Claude Code — Windows PowerShell
New-Item -ItemType Directory -Force "$HOME\.claude\skills\merge-conflict-resolver" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/git-workflow/merge-conflict-resolver/SKILL.md -UseBasicParsing -OutFile "$HOME\.claude\skills\merge-conflict-resolver\SKILL.md"
Codex, Cursor — Windows PowerShell
New-Item -ItemType Directory -Force "$HOME\.agents\skills\merge-conflict-resolver" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/git-workflow/merge-conflict-resolver/SKILL.md -UseBasicParsing -OutFile "$HOME\.agents\skills\merge-conflict-resolver\SKILL.md"

Any other agent: save the file into its skills folder, or give it the link to the file: https://anymodel.org/en/skills/git-workflow/merge-conflict-resolver/SKILL.md

SKILL.md

Raw

Merge Conflict Resolver

A conflict means two people changed the same place for different reasons. The correct result keeps both intents, and picking one side blindly silently deletes somebody's work.

1. Look at the state

git status                       # which operation (merge, rebase, cherry-pick) and which files
git diff --name-only --diff-filter=U    # files still unmerged
git log --oneline --left-right --merge  # commits on each side touching the conflict

Know which operation is running, because "ours" and "theirs" swap meaning in a rebase: during git rebase, "ours" is the branch you are rebasing onto and "theirs" is your own commit being replayed. Say this to yourself before touching any file.

2. Understand each side before editing

For every conflicted file:

git diff                         # shows the conflict hunks (combined diff)
git show :1:path/to/file         # common ancestor
git show :2:path/to/file         # ours
git show :3:path/to/file         # theirs
git log -p --merge -- path/to/file

Answer:

  • What did the base version do?
  • What did each side change, and why? Read the commit messages and related issue or PR.
  • Are the changes independent (different concerns in nearby lines) or contradictory (same behavior changed two ways)?

3. Resolve by intent

  • Independent changes: keep both; merge them into one coherent result.
  • One side moved or renamed code, the other edited it: apply the edit to the new location.
  • One side deleted code the other modified: find out whether the deletion made the edit moot; do not resurrect deleted code without reason.
  • Same lines, same goal, different implementation: choose one, keep any extra behavior (tests, edge cases) from the other.
  • Contradictory behavior: this is a decision for the user. Stop, summarize both intents in two lines each, give your recommendation and ask.
  • Generated files and lockfiles: do not hand-edit. Resolve the source (manifest, schema), then regenerate (npm install, poetry lock, go mod tidy), and check the result.

Remove every conflict marker (<<<<<<<, =======, >>>>>>>) and check none remain:

git diff --check
git grep -nE '^(<<<<<<<|>>>>>>>) |^=======$'

4. Verify the result

A conflict-free file is not a correct file.

  • Build, lint and type-check the project.
  • Run the tests, especially those touching the resolved files and anything both sides tested.
  • Read the final diff of each resolved file against both parents to confirm nothing from either side was lost:
git diff HEAD -- path/to/file          # merge: what the resolution changes vs ours
git diff MERGE_HEAD -- path/to/file    # merge: vs theirs

5. Finish the operation

git add path/to/file
git merge --continue        # or: git rebase --continue / git cherry-pick --continue

Do not create the commit if build or tests fail; fix first, or tell the user. If the resolution is going badly, git merge --abort or git rebase --abort returns to the state before the operation; recommend it and ask before running it if there is manual work in progress.

6. Report

Operation: merge main into feature/x (N files conflicted)
path/a.ts: kept both - <what each side contributed>
path/b.py: took the rebased version of the function, ported X from the other side
Needs your decision: <contradictions with your recommendation>
Checks run: <build/test commands and results>

Pitfalls

  • Never run git checkout --ours . or --theirs . over everything; it discards one side wholesale.
  • Do not resolve by deleting the conflicting block "to make it compile".
  • Do not force-push after a rebase without asking the user; it rewrites shared history.
  • Do not git reset --hard or git clean to "start over" without asking; uncommitted resolution work is lost.
  • Do not forget non-textual conflicts: both sides added a function with the same name in different places, or changed an API that the other side calls. Only the build and tests reveal these.

Source: AnyModel skills catalog · License: CC BY 4.0

Connect through AnyModel API

This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.

More from the pack Git Workflow