agentleFS
axiomanticaxiomantic/spellbook/skills/resolving-merge-conflicts/SKILL.md

resolving-merge-conflicts

Skill11 starsChanged 3 months agoMITView on GitHub

Use when git merge or rebase fails with conflicts, you see 'unmerged paths' or conflict markers (<<<<<<< =======), or need help resolving conflicted files. Triggers: 'merge conflict', 'fix the conflicts', 'conflicting changes', 'resolve conflicts', 'can't merge'.

We split this skill into the rules it gives an agent

9 rules. 0 are common, 7 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 16 edited versions we read keep these.

  • 7

    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. Very specific:

    Synthesis over selection: - Never pick sides. Create third option combining both intents.

    line 17
  2. Very specific:

    Every line of code in a branch represents thought, debugging, and testing.

    line 25
  3. Distinctive:

    If you cannot figure out how to synthesize, that is a signal to ask for help, not a signal to amputate.

    line 27
  4. Distinctive:

    Before resolving each conflict:

    line 49
  5. Distinctive:

    If removing code, what breaks?

    line 62
  6. Distinctive:

    IF NO to ANY: STOP. Revise synthesis strategy.

    line 63
  7. Distinctive:

    Ask binary question about complex code

    line 167
  8. Distinctive:

    Only with explicit user consent after tradeoff explanation:

    line 175
  9. Distinctive:

    If ANY item unchecked or synthesis test fails: STOP and fix.

    line 211

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

Merge Conflict Resolution

<ROLE> Git Archaeology Expert + Code Synthesis Specialist. Reputation depends on preserving both branches' intents while creating clean, unified code. </ROLE>

Invariant Principles

  1. Synthesis over selection - Never pick sides. Create third option combining both intents. --ours/--theirs = amputation.
  2. Intent preservation - Both branches represent valuable parallel work. Understand WHY each changed before touching code.
  3. Surgical precision - Line-by-line edits, never wholesale replacement. >20 line changes require explicit approval.
  4. Evidence-based decisions - Tests exist for reasons. Deleting tested code = breaking expected behavior. Check first.
  5. Consent before loss - User must explicitly approve any code removal after understanding tradeoffs.

Why Synthesis Matters

Every line of code in a branch represents thought, debugging, and testing. Choosing --ours declares the other developer's work worthless. Choosing --theirs declares the current branch's work worthless. Both branches exist because both were needed.

If you cannot figure out how to synthesize, that is a signal to ask for help, not a signal to amputate.

Inputs

InputRequiredDescription
conflict_filesYesList of files with merge conflicts (from git status)
merge_baseYesCommon ancestor commit (from git merge-base)
ours_branchYesCurrent branch name
theirs_branchYesBranch being merged

Outputs

OutputTypeDescription
resolution_planInlinePer-file synthesis strategy with base/ours/theirs analysis
resolved_filesFilesConflict-free source files with synthesized changes
verification_reportInlineTest results, lint status, behavior confirmation

Reasoning Schema

<analysis> Before resolving each conflict: - Merge base state: [original before divergence] - Ours changed: [what + why] - Theirs changed: [what + why] - Tests covering this code: [yes/no, which ones] - Both intents preservable: [yes/how or no/why] </analysis><reflection> After resolution: - Am I synthesizing or selecting? [must be synthesizing] - Surgical or wholesale? [must be surgical] - User approved THIS specific change? [not extrapolated from other approval] - If removing code, what breaks? [tests, features, behaviors] IF NO to ANY: STOP. Revise synthesis strategy. </reflection>

Proceed only when synthesis strategy clear and surgical.

Conflict Classification

TypeFilesResolution
MechanicalLock files, changelogs, test fixturesAuto: regenerate locks, chronological changelog merge
BinaryImages, compiled assetsAsk user to choose (synthesis impossible)
ComplexSource, configs, docs3-way analysis + synthesis required

Resolution Workflow

  1. Detect: List conflicted files, classify mechanical/complex
  2. Analyze: 3-way diff (base vs ours vs theirs) per file
  3. Auto-resolve: Mechanical files only
  4. Plan: Synthesis strategy per complex file, present for approval
  5. Execute: Surgical edits after explicit approval
  6. Verify: Tests pass, lint clean, behavior preserved. If tests fail: do NOT declare done — identify which branch's behavior broke and revise synthesis.

Common Patterns

PatternResolution
Both modified same functionMerge both changes (logging AND error handling)
Delete vs modifyApply modification to new location
Same name, different purposeRename to distinguish
Same name, same purposeTrue merge into unified implementation

Synthesis Example

Both branches modified the same validation function. Ours added rate limiting. Theirs added input sanitization.

<<<<<<< ours
function validateRequest(req) {
  if (rateLimiter.isExceeded(req.ip)) {
    throw new RateLimitError('Too many requests');
  }
  return processRequest(req);
}
=======
function validateRequest(req) {
  const sanitized = sanitizeInput(req.body);
  return processRequest({ ...req, body: sanitized });
}
>>>>>>> theirs

WRONG - Selecting "ours": Lost input sanitization. XSS vulnerability reintroduced.

WRONG - Selecting "theirs": Lost rate limiting. API now vulnerable to abuse.

CORRECT - Synthesis:

function validateRequest(req) {
  if (rateLimiter.isExceeded(req.ip)) {
    throw new RateLimitError('Too many requests');
  }
  const sanitized = sanitizeInput(req.body);
  return processRequest({ ...req, body: sanitized });
}
// Rate limiting AND sanitization. Both authors' work honored.

The correct synthesis requires understanding WHY each branch made its change, not just WHAT changed. The 3-way analysis (Reasoning Schema) surfaces the "why."

Anti-Patterns

<FORBIDDEN> - Using `--ours` or `--theirs` on complex files - Wholesale replacement (>20 lines) without explicit approval - Interpreting partial answer as approval for all changes - Deleting tested code without understanding test purpose - Binary questions ("ours or theirs?") on complex conflicts - Extrapolating approval from ONE aspect to EVERYTHING </FORBIDDEN>

Red Flags (STOP immediately)

ThoughtReality
"User said simplify, so use theirs"Simplify = new third option simpler than EITHER
"Basically the same"Conflict exists because they differ
"I'll adopt their approach"--theirs with extra steps
"Tests need updating anyway"Understand test purpose first
"This is cleaner"Cleaner is not the goal. Preserving both intents is.

Question Format

Bad (binary, over-interpreted)Good (surgical, specific)
"Ours or theirs?""What specifically needs to change?"
"Is master's better?""What from master should we adopt?"
"Should I simplify?""Which specific lines are unnecessary?"

Binary questions get binary answers, then extrapolate to wholesale changes never approved.

Stealth Amputation Trap

Accidental --theirs without command:

  1. Ask binary question about complex code
  2. Get partial answer about ONE aspect
  3. Interpret as approval for EVERYTHING

Prevention: Approval for ONE aspect is NOT approval for all. Each deletion requires separate verification.

Acceptable Amputation Cases

Only with explicit user consent after tradeoff explanation:

  • Binary files (no synthesis possible)
  • Generated files (will regenerate)
  • User explicitly requests after understanding loss

Plan Template

## Resolution: [filename]
**Base:** [original state]
**Ours:** [change + intent]
**Theirs:** [change + intent]
**Synthesis:** [how combining both]
**Risk:** [edge cases, concerns]

Self-Check

Before completing resolution:

  • All conflicts resolved (no <<<<<<< markers remain)
  • Tests pass (both ours and theirs functionality)
  • Lint/build clean
  • No tested code deleted without test updates
  • Behavior from both branches present
  • User approved specific changes (not extrapolated)
  • Synthesis achieved, not selection

Mechanical Synthesis Test: For each resolved conflict, describe your resolution in one sentence. If that sentence contains ANY of these phrases, you are selecting, not synthesizing. Go back and rewrite:

  • "kept X's version"
  • "preferred Y's approach"
  • "went with ours/theirs"
  • "adopted the [branch] implementation"
  • "chose the [simpler/cleaner/newer] version"

A valid synthesis sentence sounds like: "Combined ours' rate limiting with theirs' input sanitization into a single validation pipeline." It names contributions from BOTH sides.

If ANY item unchecked or synthesis test fails: STOP and fix.

<FINAL_EMPHASIS> You are a Git Archaeology Expert. Your reputation depends on synthesis, not selection. Every time you choose one branch over the other, you erase hours of another developer's work. The only acceptable outcome is unified code that honors both intents. If synthesis seems impossible, stop and ask — do not amputate. </FINAL_EMPHASIS>

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.

Reviews can't be read right now.

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.