| name | merge-conflict-minimal-resolver |
| description | Resolve Git merge conflicts with a least-invasive strategy that preserves existing behavior and as much content as possible. Use when files contain conflict markers, rebase/cherry-pick/merge stops on conflicts, or a branch needs safe conflict resolution that synthesizes both sides where compatible and chooses the best side only when coexistence is not possible. |
Merge Conflict Minimal Resolver
Apply conservative conflict resolution that keeps user intent and minimizes unnecessary edits.
Core Principles
- Preserve before replacing.
- Change only conflicted regions unless a tiny adjacent edit is required to compile.
- Keep both sides when semantics can coexist.
- Prefer synthesis over taking one side wholesale.
- Choose one side only for true mutual exclusivity.
- Keep formatting, ordering, and naming consistent with local file style.
- Never drop behavior silently; explain tradeoffs in the final summary.
Workflow
- Identify all conflicted files (
git status, search for <<<<<<<, =======, >>>>>>>).
- Resolve each conflict region independently; avoid large-file rewrites.
- Classify each conflict:
- Non-overlapping intent: both sides add/change different concerns.
- Same intent, different implementation: combine only the compatible parts.
- Direct incompatibility: both sides cannot be active simultaneously.
- Apply the least-invasive merge strategy:
- Keep both with minimal composition for non-overlapping intent.
- Synthesize a hybrid for same-intent differences.
- Select one side only for direct incompatibility.
- Run targeted validation (build/tests/lint relevant to touched code).
- Stage files and summarize exactly what was kept, synthesized, and chosen.
Conflict Decision Rules
Use this order:
- Coexistence check
- Keep both if behavior remains valid and non-duplicative.
- Minimal synthesis check
- Combine the smallest set of lines required to retain both intents.
- Irreconcilable check
- If both cannot coexist, pick the option with the better score:
- Correctness and testability first.
- Lower regression risk second.
- Better alignment with surrounding architecture and naming third.
- Smaller behavioral surprise for users fourth.
Avoid "take ours/theirs" for an entire file unless the file is generated/lockfile and project convention supports that choice.
Merge Patterns
Independent additions on both sides
Keep both blocks, preserve existing order where meaningful, and avoid renaming unless required.
API signature mismatch
Prefer the signature used by current call sites, then incorporate compatible improvements from the other side in implementation.
Deletion vs modification
If modified behavior is still required by active callers/tests, keep and adapt the modified version. If feature was intentionally removed and no active dependency remains, accept deletion.
Config/version conflicts
Prefer the version/config that keeps the project building now; then merge compatible config keys from both sides.
Formatting-only vs logic change
Keep the logic change; reapply formatting style afterward.
Guardrails
- Remove all conflict markers before finishing.
- Keep diffs surgical; do not opportunistically refactor.
- Keep comments and docs if still accurate; update only where behavior changed.
- Preserve public interfaces unless conflict resolution requires a coordinated update.
- If a choice is ambiguous, document the assumption and pick the safest reversible option.
Validation Checklist
- Confirm no markers remain:
rg -n '^(<<<<<<<|=======|>>>>>>>)'.
- Run the smallest reliable verification set for touched components.
- Ensure no duplicate logic was introduced by combining both sides.
- Ensure imports/includes/build settings are consistent after synthesis.
- Verify
git diff --staged is conflict-focused and minimally invasive.
Output Template
Report conflict resolution using:
- Files resolved.
- For each file: what was kept from each side.
- Where synthesis occurred and why.
- Where one side was chosen and why coexistence failed.
- Validation commands run and outcomes.