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.zipInstalls 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\".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
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:
| Question | How 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:
| Side | Merge | Rebase |
|---|---|---|
<<<<<<< HEAD (ours) | Your branch | Upstream (e.g., main) |
======= → >>>>>>> (theirs) | Incoming branch | Your 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:
- Treat the theirs section as the change you must land; treat the ours section as context to integrate around it.
- If both sides modified the same lines with incompatible intent, ask the user (see "When uncertain" below).
- "Upstream looks newer/cleaner" is NOT sufficient justification to drop theirs.
Standard conflicts (UU — both modified, AA — both added)
- Understand intent of both sides from history and surrounding code.
- Choose resolution strategy:
| Situation | Strategy |
|---|---|
| Changes are independent (different functions, different lines) | Merge both — keep all changes |
| Changes overlap but complement each other | Combine intelligently — integrate both intents |
| Changes contradict each other | Ask the user (see "When uncertain" below) |
| One side is strictly newer/better | git 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. |
- Remove ALL conflict markers (
<<<<<<<,=======,>>>>>>>). - 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:
- List both sides' meaningful changes.
For each side, write a one-line summary of what it intended (from Step 2's
git showanalysis). - 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.
- Respect intentional removals.
If one side removed code that the other side still has (or modified):
git showthe 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.
- 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.
| Rationalization | Reality |
|---|---|
| "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 wholesale | NOT safe — must merge manually |
|---|---|
| Other side's changes are formatting/whitespace only | Both sides have substantive logic changes |
| Other side only reordered imports | Both 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 other | Both 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)
- Identify which side deleted and which modified.
- 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>
- Classify the deletion:
| Deletion context | Resolution |
|---|---|
| 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 message | Ask the user — deletion may have been accidental |
- 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)
- Review the added file's content and purpose.
- If keeping:
git add <file> - If removing:
git rm <file> - 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.
| File | How 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.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| fix-conflicts (this skill) | 0 | 2mo | Review | Advanced |
| resolve-conflicts | 81 | 8mo | Review | Intermediate |
| dependency-upgrade | 26 | 5mo | Review | Intermediate |
| openspec-onboard | 10 | 6mo | Review | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by rtfpessoa
View all by rtfpessoa →You might also like
resolve-conflicts
antinomyhq
Use this skill immediately when the user mentions merge conflicts that need to be resolved. Do not attempt to resolve conflicts directly - invoke this skill first. This skill specializes in providing a structured framework for merging imports, tests, lock files (regeneration), configuration files, and handling deleted-but-modified files with backup and analysis.
dependency-upgrade
wshobson
Manage major dependency version upgrades with compatibility analysis, staged rollout, and comprehensive testing. Use when upgrading framework versions, updating major dependencies, or managing breaking changes in libraries.
openspec-onboard
studyzy
Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
codex-cli-bridge
alirezarezvani
Bridge between Claude Code and OpenAI Codex CLI - generates AGENTS.md from CLAUDE.md, provides Codex CLI execution helpers, and enables seamless interoperability between both tools
skill-sync
KyleKing
Syncs Claude Skills with other AI coding tools like Cursor, Copilot, and Codeium by creating cross-references and shared knowledge bases. Invoke when user wants to leverage skills across multiple tools or create unified AI context.
git-commits
bonny
Create well-structured git commits in logical chunks following best practices