agentleFS
TacuchiTacuchi/agent-skills/skills/git/resolving-merge-conflicts/SKILL.md

resolving-merge-conflicts

Skill0 starsChanged 2 months agoMITView on GitHub

Use when a Git merge is in progress, a file has merge conflict markers, or the user asks to resolve, resume, or diagnose merge conflicts in any repository. Inspect the merge base, ours, theirs and their intent before choosing; resolve selected files incrementally, preserve unrelated changes, ask about ambiguous hunks, and run the merged checkout's build and tests before proposing an approved commit. Works with Git alone, including after an interrupted merge. For general commit/branch rules, use the `git-conventions` skill if available; follow the repository's own instructions for branch directions.

153 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use decision-mapping, setup-ts-deep-modules and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • FabienDehopreSkill

    decision-mapping

    Turn a loose idea into a sequenced map of investigation tickets, then drive them to resolution one at a time.

    Also in 5 projects that use this

  • liufeng1976Skill

    setup-ts-deep-modules

    Wire dependency-cruiser into a TypeScript repo so each package is a deep module — implementation hidden in subfolders, reachable only through its entry-point files. User-invoked.

    Also in 30 projects that use this

  • richard12511Skill

    claude-handoff

    Hand the current conversation off to a fresh background agent that picks up the work immediately.

    Also in 30 projects that use this

  • RoentekSkill

    loop-me

    Grill me about specs for the workflows I want to build, within this workspace.

    Also in 34 projects that use this

  • LesaniSkill

    writing-beats

    Shape an article as a journey of beats, choose-your-own-adventure style. The user picks a starting beat from the raw material, you write only that beat, then offer options for where to pivot next, beat by beat, until the article reaches a natural end. Use when the user has raw material and wants to assemble it as a narrative rather than an argument.

    Also in 34 projects that use this

  • LesaniSkill

    writing-fragments

    Grilling session that mines the user for fragments — heterogeneous nuggets of writing (claims, vignettes, sharp sentences, half-thoughts) — and appends them to a single document as raw material for a future article. Use when the user wants to develop ideas before imposing structure, or mentions "fragments", "ideate", or "raw material" for writing.

    Also in 34 projects that use this

  • +1 more from Lesani

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 3 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 18 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run this once, when the skill loads and before its other steps.

    line 10
  2. Very specific:

    Run node <skill dir>/scripts/permissions.mjs check --root <session folder> --host <claude|codex|agy>.

    line 12
  3. Very specific:

    If node is missing or the command fails, say so, list the needs in <skill dir>/permissions.json and go on with the skill.

    line 13
  4. Very specific:

    Read hosts.<host> in the output.

    line 14
  5. Very specific:

    Run the command of the option the person chose, exactly as given.

    line 16
  6. Distinctive:

    After "Skip for now", do not run this step again in the session.

    line 18
  7. Very specific:

    If there is no MERGE_HEAD, report the actual state.

    line 35
  8. Very specific:

    Read the neighboring code, relevant commits (git log --oneline --all -- <path>) and repository instructions.

    line 45
  9. Very specific:

    If the right behavior, a binary side, a missing stage or a semantic adjustment is ambiguous, stop on that path and show base/ours/theirs …

    line 64
  10. Distinctive:

    If the merge itself must be abandoned, explain the effect and request separate authorization for git merge --abort.

    line 70

“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Resolving merge conflicts

Step 0 — Permissions this skill uses

Run this once, when the skill loads and before its other steps. It keeps the session from stopping on a prompt for a command this skill is known to run. It is not a security check: the host and its hooks still decide.

  1. Run node <skill dir>/scripts/permissions.mjs check --root <session folder> --host <claude|codex|agy>. <skill dir> is the folder of this SKILL.md; <session folder> is the folder where the session started; the host is the one you run in.
  2. If node is missing or the command fails, say so, list the needs in <skill dir>/permissions.json and go on with the skill.
  3. Read hosts.<host> in the output. Show its notice when there is one.
  4. Ask each entry of its questions with the host's structured question tool, in the person's language: its text, then its options in the given order, the one marked recommended first. Low-risk and high-risk needs are separate questions; ask them separately and never recommend allowing a high-risk need.
  5. Run the command of the option the person chose, exactly as given. An option without a command writes nothing. Write nothing the person did not choose.
  6. Tell the person the applies line of the result: whether the change works now or after a restart. If the command fails, say so and go on.
  7. After "Skip for now", do not run this step again in the session.

Boundary

Resolve a merge already in progress in the affected Git checkout. A request to start a merge is a separate decision: inspect the branch and ask for its explicit authorization first. This skill uses Git and the repository's own instructions and runners; no workspace manager, plugin or particular host installation is required. Do not resolve a rebase or cherry-pick as if it were a merge (REBASE_HEAD / CHERRY_PICK_HEAD have different exits).

Inspect before editing

  1. In the affected checkout, run git status --short --branch, git status, git rev-parse --git-path MERGE_HEAD and check that the returned file exists. Read git rev-parse HEAD, git rev-parse MERGE_HEAD, git ls-files -u and git diff --name-only --diff-filter=U. If there is no MERGE_HEAD, report the actual state; if it exists but no unmerged paths remain, resume at the closing checks (not a new merge).
  2. git merge-base --all HEAD MERGE_HEAD identifies ancestry. Several bases mean the index's :1: may be Git's virtual base: inspect each base with git show <base>:<path> where present, and ask if their intent is unclear. With one base, git show :1:<path> is the index base. For each unmerged path inspect git ls-files -u -- <path> and git show :2:<path> (ours, current branch) / git show :3:<path> (theirs, incoming branch); a missing stage denotes add/delete and cannot be selected as a file. Binary paths need explicit evidence for retaining an intact side or deleting the file.
  3. Read the neighboring code, relevant commits (git log --oneline --all -- <path>) and repository instructions. Identify what each side intended, including a rename or a deletion; never choose a whole side just because it is shorter. Inventory cleanly merged files that depend on the conflict, plus pre-existing staged, unstaged and untracked work. Name foreign work before any edit; do not overwrite, stash, reset, clean or stage it.

Resolve in small, reversible steps

  • For an unambiguous path, edit only that path to integrate both intents; preserve encoding, line endings and executable mode. A justified intact-side selection for a binary or add/delete conflict still needs the user's intended result. Check git diff --check -- <path>, inspect the file and stage only this resolved path with git add -- <path> (or git rm -- <path> for a justified deletion). Never stage all files with git add ..
  • A subset is enough: rerun git ls-files -u and git status after each application. Record what was resolved, what remains and what was untouched; the index plus MERGE_HEAD are the resume state after an interruption. Resolve another path later without reapplying work already staged.
  • If the right behavior, a binary side, a missing stage or a semantic adjustment is ambiguous, stop on that path and show base/ours/theirs with the consequence of each plausible choice. Wait for the person's written decision; leave MERGE_HEAD, index and files intact. You may continue independent, unambiguous paths first. To change a cleanly merged related file, inspect its staged and worktree versions and establish ownership before editing/staging it.
  • If the merge itself must be abandoned, explain the effect and request separate authorization for git merge --abort; never use it as an automatic recovery.

What a clean auto-merge can still break

Git reporting no conflict does not make the result right.

  • An auto-merge can drop an import, a parameter or a method from one side, duplicate a block that the other side moved, or accept a rename on one branch and new calls to the old name on the other. Build the merged tree even when no path conflicted: the compiler is the only detector.
  • With crossed bases, a merge can bring back, with no conflict, something one branch deleted. Review the deletions by hand.
  • Markers may already be committed in either branch, from an earlier merge or a stash pop. Look for them before trusting the result: git grep -n -e '^<<<<<<< ' -e '^>>>>>>> ' -- .
  • git checkout --ours -- <path> (or --theirs) leaves the path unmerged: it still needs git add -- <path>.
  • Normalize line endings on both sides before measuring one against :2: or :3:: a CRLF/LF difference makes every line look changed.

Close only after checking the merged checkout

  1. git ls-files -u must be empty; git diff --check and git diff --cached --check must pass. Read git status, git diff --cached --stat and git diff --cached for the whole merge, including changes Git staged automatically. Identify any unrelated staged files and unstaged/untracked work; do not include somebody else's work. The test runner reads the worktree: if it differs materially from the staged merge, reconcile your own changes and pause on foreign changes rather than claiming the staged result was tested.
  2. Discover the versioned build and test commands of the destination repo (its pipeline, package scripts, wrapper or instructions). Run both on this merged checkout, not on the source branch. If a command is undeclared or cannot run, report the blocker and leave the merge open. If a failure is claimed pre-existing, demonstrate it with the same command on an untouched base separately; do not discard the merge to test that claim. After fixes, rerun affected checks and inspect status and index again.
  3. Propose the exact included paths, one-line message and results of both commands. Ask the person to approve the merge commit; do not create it while awaiting approval. Once explicitly approved, recheck MERGE_HEAD, branch, git ls-files -u and staged paths, then commit with normal hooks (no --no-verify, amend or push). If state changed, stop and re-inspect instead of using a stale approval. Report the new commit or, if still pending, the remaining paths and next action.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.