agentleFS
nortonxnortonx/ai-tooling-free/skills/resolve-merge-conflicts/SKILL.md

resolve-merge-conflicts

Skill1 starsChanged 2 months agoMITView on GitHub

Use when git merge, rebase, or cherry-pick halts on conflict markers, unmerged paths, or merge conflicts in source files or lockfiles.

  • Deletes or force-pushes

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use diagnose-ci-failures, write-product-spec and 6 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.
  • zerx-labSkill

    diagnose-ci-failures

    Diagnose CI failures for a PR using the GitHub CLI, extract error logs, and generate a plan to fix them. Use when the user asks to check CI status, pull CI issues, triage test failures, or investigate PR build failures.

    Also in 3 projects that use this

  • zerx-labSkill

    write-product-spec

    Write a PRODUCT.md spec for a significant user-facing feature in Zap, focused on detailed behavior and validation. Use when the user asks for a product spec, desired behavior doc, or PRD, wants to define feature behavior before implementation, or when the feature is substantial or behaviorally ambiguous enough that a written spec would improve implementation or review.

    Also in 3 projects that use this

  • charlesmatteSkill

    write-tech-spec

    Generate a technical specification document from an existing PRD through relentless technical interview and codebase exploration. Use when user wants to write a tech spec, technical specification, technical design document, TDD (technical design doc), or go deeper on the technical details of a PRD.

    Also in 3 projects that use this

  • gitpod-ioSkill

    fix-errors

    Guidelines for fixing unhandled errors from the VS Code error telemetry dashboard. Use when investigating error-telemetry issues with stack traces, error messages, and hit/user counts. Covers tracing data flow through call stacks, identifying producers of invalid data vs. consumers that crash, enriching error messages for telemetry diagnosis, and avoiding common anti-patterns like silently swallowing errors.

    Also in 3 projects that use this

  • busybutlazySkill

    update-skill

    Use this skill when the user wants to modify an existing public skill in this repository's canonical-skills, revise its workflow, or update its package metadata and version.

    Also in 3 projects that use this

  • DockerSkill

    review-pr

    Review one or more incoming Docker documentation pull requests as a maintainer. Independently validate technical claims, assess editorial fit and information architecture, choose a verdict, and draft exact inline or PR-wide feedback behind a confirmation gate. Use for requests such as "review PR 123", "is this PR correct?", "does this information belong here?", "validate this PR", or "help review backlog PRs". Do not use to maintain or fix a PR you own; use maintain-pr for that.

    Also in 3 projects that use this

  • +2 more from zerx-lab

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. 0 are common, 14 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 14

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 14
  2. Distinctive:

    Run git status to determine:

    line 47
  3. Very specific:

    If in a rebase, note the rebase target (onto) and the commit being applied.

    line 50
  4. Distinctive:

    Run the package manager's install command to recalculate the lockfile graph deterministically:

    line 63
  5. Distinctive:

    Verify the lockfile updated cleanly and stage both the manifest and the lockfile.

    line 69
  6. Distinctive:

    If both added imports or dependencies, keep both (sorted, deduplicated).

    line 85
  7. Distinctive:

    If one updated a function signature and the other added call sites, update the call sites to match the new signature.

    line 86
  8. Distinctive:

    If both edited the same configuration block, merge keys without dropping either side's new settings.

    line 87
  9. Very specific:

    Remove all conflict markers (<<<<<<<, =======, >>>>>>>).

    line 88
  10. Distinctive:

    Check for leftover markers:

    line 95
  11. Distinctive:

    If any marker remains, Git prints the file and line number.

    line 99
  12. Distinctive:

    Run language typechecking and linting:

    line 100
  13. Distinctive:

    Run affected test suites to verify that both features still work together.

    line 105
  14. Distinctive:

    Ensure no unmerged paths remain.

    line 117
  15. Distinctive:

    If merging: git commit (or git merge --continue).

    line 119
  16. Distinctive:

    If rebasing across multiple commits, repeat Steps 1 to 5 for each conflicting commit until the rebase completes.

    line 122

“Common” is measured: kept by at least 6 in 10 of the 12 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

Resolve Merge Conflicts

Overview

A merge conflict occurs when two branches make conflicting assumptions about the same lines or files. Resolving a conflict means understanding the intent of both changes, reconciling them into a coherent whole, and verifying syntactic and semantic correctness before continuing.

When to Use

Use this skill when:

  • Git stops during merge, rebase, cherry-pick, or stash pop with CONFLICT (content) or unmerged paths.
  • Files contain conflict markers (<<<<<<<, =======, >>>>>>>).
  • Machine-generated lockfiles (package-lock.json, pnpm-lock.yaml, Cargo.lock) conflict after dependency updates.
  • Git status reports unmerged paths (UU, AA, UD, DU).

Quick Reference

TaskCommandCaveat
List unmerged filesgit status --short (look for UU, AA, UD)Run first before touching code
Show conflict markersgit diff --checkDetects leftover <<<<<<< markers
View 3-way diffgit diffShows conflict blocks with local vs incoming
View base, ours, theirsgit show :1:<file> (base), :2:<file> (ours), :3:<file> (theirs)Inspect original shared ancestor
Stage resolved filegit add <file>Only after verifying syntax and tests
Continue operationgit merge --continue or git rebase --continueNever commit directly during rebase
Abort safelygit merge --abort or git rebase --abortReturns working tree to clean pre-op state

The Rebase Inversion Trap

The meaning of --ours and --theirs depends on the operation:

OperationHEAD represents--ours refers to--theirs refers to
git mergeCurrent branchCurrent branch (target)Incoming branch (source)
git rebaseUpstream target commitUpstream branch (rebase target)Your feature branch (commit being replayed)

In a rebase, Git checks out the upstream target and replays feature commits on top. Running git checkout --ours during a rebase discards your feature branch changes and retains upstream. Running git checkout --theirs keeps your feature branch and discards upstream.

Resolution Protocol

Step 1: Identify and Orient

  1. Run git status to determine:
    • Operation type: merge, rebase, cherry-pick, or revert.
    • List of unmerged paths.
  2. If in a rebase, note the rebase target (onto) and the commit being applied.
  3. Identify file categories:
    • Source code files (require surgical reconciliation).
    • Lockfiles and generated files (require manifest resolution followed by regeneration).
    • Deleted files (one side deleted, one side modified).

Step 2: Separate Code from Lockfiles

Never manually edit conflict markers in generated lockfiles (pnpm-lock.yaml, package-lock.json, yarn.lock, Cargo.lock, poetry.lock).

For lockfiles:

  1. Reconcile the human-edited manifest first (package.json, Cargo.toml, pyproject.toml).
  2. Accept one version of the lockfile temporarily (e.g. git checkout --ours -- <lockfile>).
  3. Run the package manager's install command to recalculate the lockfile graph deterministically:
    • pnpm: pnpm install
    • npm: npm install
    • yarn: yarn install
    • cargo: cargo generate-lockfile (or cargo check)
    • poetry: poetry lock --no-update
  4. Verify the lockfile updated cleanly and stage both the manifest and the lockfile.

Step 3: Surgically Reconcile Source Files

  1. Open each conflicting file and locate every conflict block:
    <<<<<<< HEAD
    current changes
    =======
    incoming changes
    >>>>>>> branch-or-commit
  2. Understand the intent of both sides:
    • Why did branch A make this change?
    • Why did branch B make this change?
  3. Combine the changes so both intents survive:
    • If both added imports or dependencies, keep both (sorted, deduplicated).
    • If one updated a function signature and the other added call sites, update the call sites to match the new signature.
    • If both edited the same configuration block, merge keys without dropping either side's new settings.
  4. Remove all conflict markers (<<<<<<<, =======, >>>>>>>).
  5. Touch only the conflicting lines and necessary call sites. Do not reformat or refactor adjacent code.

Step 4: Verify Syntactic and Semantic Correctness

Removing conflict markers is only textual reconciliation. You must verify semantics:

  1. Check for leftover markers:
    git diff --check
    If any marker remains, Git prints the file and line number. Fix immediately.
  2. Run language typechecking and linting:
    • TypeScript/JavaScript: npm run typecheck or npx tsc --noEmit
    • Python: mypy . or python syntax check python -m py_compile <file>
    • Go: go vet ./...
    • Rust: cargo check
  3. Run affected test suites to verify that both features still work together.

Step 5: Stage and Conclude

  1. Stage resolved files:
    git add <resolved-file>
  2. Check status:
    git status
    Ensure no unmerged paths remain.
  3. Conclude the step:
    • If merging: git commit (or git merge --continue).
    • If rebasing: git rebase --continue.
    • If cherry-picking: git cherry-pick --continue.
  4. If rebasing across multiple commits, repeat Steps 1 to 5 for each conflicting commit until the rebase completes.

Rationalization Table

ExcuseReality
"Deploy window closes soon, take ours to make it fast"Discarding either side breaks production functionality or compliance. Fast bad merges cause immediate production outages. Reconcile both or abort.
"I will resolve the text now and fix compilation in a follow-up commit"Half-merged commits break git bisect, fail CI gates, and risk shipping broken code. Verify before continuing.
"The conflict was only 2 lines, running tests is unnecessary"Two-line changes in signatures or configs cause runtime exceptions. Always run compiler checks or tests.
"Teammate said run checkout --ours"During rebase, --ours is the upstream branch, not your feature branch. Blind checkout silently deletes feature code.
"I can hand-edit the 200 lines of conflict in pnpm-lock.yaml"Hand-edited lockfiles corrupt dependency trees and checksums. Reconcile package.json and run the package manager install command.
"Git status shows no markers, so the merge succeeded"Removing markers resolves text layout, not semantic compatibility. New calls to changed signatures still fail.

Red Flags: STOP and Review

  • Using git checkout --ours or git checkout --theirs on whole source files without line-by-line inspection.
  • Staging files before running git diff --check.
  • Running git rebase --continue or git commit without running typechecks or tests.
  • Manually editing YAML or JSON in lockfiles.
  • Running git reset --hard or deleting files when confused by rebase state (use --abort instead).
  • Refactoring lines outside the conflict region during resolution.

Common Mistakes

MistakeSymptomFix
Direct commit during rebaseDetached HEAD or nested commit loopStage with git add <file> and run git rebase --continue
Dropping settings in configsMissing feature flag or keyCombine all new keys into the config dictionary
Deleted vs Modified (UD/DU)CONFLICT (modify/delete)Run git add <file> to retain or git rm <file> to delete

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.