FI

fix-conflicts

Identifies and resolves Git conflicts through automated state detection and history analysis.

Install

mkdir -p .claude/skills/fix-conflicts && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13113" && unzip -o skill.zip -d .claude/skills/fix-conflicts && rm skill.zip

Installs to .claude/skills/fix-conflicts

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Use when git reports merge conflicts, rebase conflicts, cherry-pick conflicts, or revert conflicts, or when the user asks to resolve conflicts. Triggers: \"fix conflicts\", \"resolve conflicts\", \"merge conflicts\", \"rebase conflicts\", \"fix merge\", \"resolve merge\", \"help with conflicts\", \"conflict markers\".
319 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Detect the type of Git conflict (merge, rebase, revert, cherry-pick)
  • Identify conflicted files and their conflict types
  • Read conflicted files and focus on conflict markers
  • Gather local and remote commit history for context
  • Inspect commit diffs to understand intent
  • Resolve standard conflicts by merging, combining, or choosing sides

How it works

The skill detects the conflict state, reads conflicted files, gathers commit history to understand intent, and then resolves conflicts based on type and intent, reporting the results.

Inputs & outputs

You give it
A Git repository in a conflicted state
You get back
Files with conflict markers resolved, and a summary report of resolutions

When to use fix-conflicts

  • Fixing merge conflicts
  • Resolving rebase conflicts
  • Fixing cherry-pick conflicts

About this skill

Fix Conflicts

Announce: "I'm using the fix-conflicts skill to resolve merge conflicts."

Step 1: Detect Conflict State

Run the conflict state detector:

./scripts/get-conflict-state.sh

The output shows the operation type (merge, rebase, revert, cherry-pick), conflicted files with their conflict types, and branch context.

If Operation is "none" and no conflicted files: inform the user there are no conflicts to resolve and stop.

If the user's invocation prompt specifies a file: limit resolution scope to that file only (verify it appears in the conflicted list).

Step 2: Read Conflicted Files

Read every conflicted file listed in Step 1. For large files (>500 lines), focus on sections containing conflict markers (<<<<<<<, =======, >>>>>>>).

Then gather history context to understand what each side intended:

# Local commits that touched conflicted files
./scripts/get-conflict-history.sh local

# Remote commits that touched conflicted files
./scripts/get-conflict-history.sh remote

For each commit listed in the history output, inspect its actual diff to understand intent:

# Show the full diff for a specific commit touching the conflicted file
git show <commit-sha> -- <conflicted-file>

Pay attention to:

  • Additions: new code, new functions, new parameters
  • Removals: deleted code, removed functions, removed parameters — note whether the commit message explains the removal (refactor, deprecation, cleanup) or whether the removal looks incidental to a larger change
  • Modifications: changed logic, renamed symbols, updated signatures

For each conflict, determine:

QuestionHow to answer
What did the local side change?git show each local commit touching the file; inspect code between <<<<<<< HEAD and =======
What did the remote side change?git show each remote commit touching the file; inspect code between ======= and >>>>>>>
Did either side intentionally remove code?Check if the removal was in a dedicated commit (refactor/cleanup/deprecation) vs. incidental to a larger change
Are changes independent?Different logical concerns = keep both
Are changes contradictory?Same logic changed differently = need judgment

Step 3: Resolve by Conflict Type

Rebase conflict orientation (CRITICAL)

During git rebase, ours/theirs are reversed from merge:

SideMergeRebase
<<<<<<< HEAD (ours)Your branchUpstream (e.g., main)
=======>>>>>>> (theirs)Incoming branchYour feature branch

The code between ======= and >>>>>>> is YOUR feature branch work. Never discard it without explicit user confirmation — doing so silently loses changes you wrote.

Resolution posture during rebase:

  1. Treat the theirs section as the change you must land; treat the ours section as context to integrate around it.
  2. If both sides modified the same lines with incompatible intent, ask the user (see "When uncertain" below).
  3. "Upstream looks newer/cleaner" is NOT sufficient justification to drop theirs.

Standard conflicts (UU — both modified, AA — both added)

  1. Understand intent of both sides from history and surrounding code.
  2. Choose resolution strategy:
SituationStrategy
Changes are independent (different functions, different lines)Merge both — keep all changes
Changes overlap but complement each otherCombine intelligently — integrate both intents
Changes contradict each otherAsk the user (see "When uncertain" below)
One side is strictly newer/bettergit show both sides' commits — only keep one side if the other's changes are already included or purely cosmetic. During rebase, verify "better" is not just upstream recency.
  1. Remove ALL conflict markers (<<<<<<<, =======, >>>>>>>).
  2. Verify the result is syntactically correct.

Intent preservation rules (apply to ALL conflict types)

Before writing the resolved version of any conflict, complete this checklist:

  1. List both sides' meaningful changes. For each side, write a one-line summary of what it intended (from Step 2's git show analysis).
  2. Verify no silent drops. If you are keeping only one side's text, confirm the other side made no substantive changes (logic, behavior, API) in that region. Formatting-only or whitespace-only differences are safe to drop.
  3. Respect intentional removals. If one side removed code that the other side still has (or modified):
    • git show the commit that performed the removal.
    • If the commit message or diff shows a deliberate action (refactor, deprecation, dead-code cleanup, feature removal), do not re-add the removed code — the removal wins.
    • If the removal looks incidental (part of a large unrelated change, no mention in the commit message), ask the user whether the removal was intentional.
  4. Never re-add intentionally deleted code. Code that was removed in a dedicated cleanup or refactor commit must stay removed, even if the other side's conflict block still contains it.
RationalizationReality
"I'll keep both sides to be safe"Re-adding intentionally deleted code is not safe — it reverses a deliberate decision
"The other side still has it, so it must be needed"The other side's branch may predate the removal
"One side is newer so I'll take that whole block"The older side may contain additions the newer side never saw

Wholesale side selection guardrails

Taking an entire side (--ours / --theirs or keeping one conflict block verbatim) is only safe when the other side's changes in that region are trivially reconcilable.

Safe to take one side wholesaleNOT safe — must merge manually
Other side's changes are formatting/whitespace onlyBoth sides have substantive logic changes
Other side only reordered importsBoth sides added new code in the same region
Conflict is in a generated or lock file (will be regenerated)One side removed code the other side modified
One side's change is a strict subset of the otherBoth sides changed function signatures differently

Before selecting a whole side, run git show <commit> -- <file> for the side you would drop and confirm its changes are present elsewhere or are not meaningful.

Modify/delete conflicts (UD — modified locally/deleted remotely, DU — deleted locally/modified remotely)

  1. Identify which side deleted and which modified.
  2. Inspect the deletion commit to determine intent:
# Find the commit that deleted the file on the deleting side
git log --diff-filter=D --oneline -1 -- <file>

# Examine the commit to understand why
git show <deletion-commit-sha>
  1. Classify the deletion:
Deletion contextResolution
Dedicated cleanup/refactor commit (message says "remove", "deprecate", "delete", "clean up")Deletion was intentional — default to deleting unless the modification is critical new work
Feature commit that reorganized code (moved, not removed)Check where the code moved to; merge the modification into the new location
Incidental to a large commit with no mention in the messageAsk the user — deletion may have been accidental
  1. If still uncertain, ask the user:

Pause and ask the user. Wait for their answer before proceeding.

Keep or delete? -- <file> was modified on one side but deleted on the other. The modification: <brief description>. The deletion was in commit <sha>: <message>. The deletion appears <intentional|incidental>. Keep the modified version or delete?

  • Keep modified -- Stage the modified version with git add
  • Delete -- Stage deletion with git rm

Add conflicts (AU — added by us, UA — added by them)

  1. Review the added file's content and purpose.
  2. If keeping: git add <file>
  3. If removing: git rm <file>
  4. If both sides added with different content: treat as a standard UU conflict.

When uncertain about any conflict

Do NOT guess about business logic. Ask the user.

For merge conflicts:

Pause and ask the user. Wait for their answer before proceeding.

Conflict choice -- Conflict in <file>: <brief description of both sides>. How should this be resolved?

  • Keep local (ours) -- Use the local/HEAD version
  • Keep remote (theirs) -- Use the incoming version
  • Merge both -- Combine changes from both sides
  • Leave unresolved -- Skip this file for manual resolution

For rebase conflicts (ours = upstream, theirs = your feature branch):

Pause and ask the user. Wait for their answer before proceeding.

Conflict choice (rebase) -- Conflict in <file> while replaying your commit '<commit message>'. Upstream (HEAD) has: <ours summary>. Your branch has: <theirs summary>. How should this be resolved?

  • Keep your branch change (theirs) -- Preserve your feature branch work
  • Keep upstream (ours) -- Discard your branch's version for this section
  • Merge both -- Combine both sides
  • Leave unresolved -- Skip this file for manual resolution

Version and changelog conflicts

When a version field or changelog conflicts, the upstream (main) side has released a new version. NEVER merge version entries. The upstream release history is immutable.

Resolution rule: Keep all upstream version entries and release notes exactly as they are. Bump your version to be strictly above the upstream version, then add your changelog entry as the newest.

FileHow to resolve
Version fields (package.json version, plugin.json version, Cargo.toml version, pyproject.toml version)Take the upstream version. If your version was equal or higher, bump to t

Content truncated.

When not to use it

  • When there are no Git conflicts to resolve
  • When the user explicitly wants to continue the Git operation automatically
  • When the user wants to re-add intentionally deleted code

Limitations

  • Never automatically run `git merge --continue` or similar commands
  • Does not re-add intentionally deleted code
  • Semantic conflicts (compiles but logically wrong) are flagged as risks

How it compares

This skill provides a structured, analytical approach to resolving Git conflicts by examining commit history and intent, rather than simply choosing 'ours' or 'theirs' blindly.

Compared to similar skills

fix-conflicts side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
fix-conflicts (this skill)02moReviewAdvanced
resolve-conflicts818moReviewIntermediate
dependency-upgrade265moReviewIntermediate
openspec-onboard106moReviewBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry