conflict-resolve
Skill1 starsChanged 7 months agoMITView on GitHub
Guided conflict resolution with semantic analysis and validation
- Deletes or force-pushes
- Installs packages
In this repository206 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- project-healthSkill
- skill-validatorSkill
- accessibilitySkill
- agent-debugSkill
- agent-evaluateSkill
- ai-governanceSkill
- ai-system-reviewSkill
- api-docs-generateSkill
- api-examplesSkill
- api-mockSkill
- api-test-generateSkill
- api-validateSkill
- architecture-diagramSkill
- ask-mattSkill
- assumption-mapSkill
- boilerplateSkill
- brainstormSkill
- branch-finishSkill
- briefingSkill
- browser-testing-with-devtoolsSkill
- bundle-analyzeSkill
- cache-strategySkill
- canarySkill
- carefulSkill
- cavemanSkill
- changelog-autoSkill
- chaos-testSkill
- ci-setupSkill
- ci-sweepSkill
- cleanprojectSkill
- click-path-auditSkill
- codebase-designSkill
- code-review-checklistSkill
- code-tourSkill
- commitSkill
- completion-verifySkill
- complexity-reduceSkill
- component-librarySkill
- config-cleanupSkill
- config-generateSkill
- container-optimizeSkill
- context-budgetSkill
- context-engineeringSkill
- context-restoreSkill
- context-saveSkill
- continuous-learningSkill
- contributingSkill
- cost-trackSkill
- councilSkill
- create-todosSkill
- cross-modal-reviewSkill
- database-connectSkill
- db-diagramSkill
- ddd-modelSkill
- debug-root-causeSkill
- debug-sessionSkill
- debug-systematicSkill
- decision-logSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 17 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈17
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Test validation after resolution
- Distinctive: line 30
Read cached state on subsequent runs (50 tokens vs 650 tokens fresh)
- Very specific: line 36
Check for MERGE_HEAD or rebase-merge directory (50 tokens)
- Distinctive: line 37
If no merge/rebase in progress: return "No conflicts" (80 tokens)
- Distinctive: line 42
Pattern: Use git commands for conflict detection
- Distinctive: line 45
No Task agents for conflict detection
- Distinctive: line 56
Pattern: Use predefined resolution patterns
- Distinctive: line 59
No creative strategy generation
- Distinctive: line 73
Read only files being resolved
- Distinctive: line 77
Pattern: Run minimal tests after resolution
- Distinctive: line 79
Run only tests for affected files
- Distinctive: line 98
Before resolving conflicts, I'll verify:
- Distinctive: line 428
Look for conflict markers:
- Distinctive: line 437
Remove ALL conflict markers
- Distinctive: line 777
Check for conflict markers
- Distinctive: line 779
Test after each resolution
- Distinctive: line 784
Check no markers remain
- Distinctive: line 799
Build fails: Check dependencies
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Guided Conflict Resolution
I'll help you resolve merge conflicts with semantic analysis and intelligent strategy recommendations.
Arguments: $ARGUMENTS - strategy (ours/theirs/manual) or file path
Conflict Resolution Philosophy
Resolve conflicts intelligently:
- Semantic conflict analysis
- Strategy recommendation (ours/theirs/manual)
- Side-by-side diff display
- Test validation after resolution
- Integration with
/testskill
Token Optimization
This skill uses conflict resolution-specific patterns to minimize token usage:
1. Conflict State Caching (600 token savings)
Pattern: Cache conflict detection and file lists
- Store conflict state in
.conflict-resolve-cache(5 min TTL) - Cache: conflicted files, conflict types, merge/rebase status
- Read cached state on subsequent runs (50 tokens vs 650 tokens fresh)
- Invalidate on git status changes
- Savings: 92% on repeated conflict checks during resolution
2. Early Exit for No Conflicts (95% savings)
Pattern: Detect no-conflict state immediately
- Check for MERGE_HEAD or rebase-merge directory (50 tokens)
- If no merge/rebase in progress: return "No conflicts" (80 tokens)
- Distribution: ~40% of runs are conflict status checks
- Savings: 80 vs 2,500 tokens for no-conflict checks
3. Bash-Based Conflict Detection (800 token savings)
Pattern: Use git commands for conflict detection
- List conflicts:
git diff --name-only --diff-filter=U(100 tokens) - Show conflict markers:
git diff --check(100 tokens) - No Task agents for conflict detection
- Savings: 80% vs Task-based conflict analysis
4. Sample-Based Conflict Analysis (1,000 token savings)
Pattern: Analyze first 5 conflicted files in detail
- Full semantic analysis for first 5 files (800 tokens)
- Summary count for remaining conflicts
- Detailed analysis only if explicitly requested
- Savings: 70% vs analyzing every conflicted file
5. Template-Based Resolution Strategies (700 token savings)
Pattern: Use predefined resolution patterns
- Standard strategies: accept ours, accept theirs, manual merge
- Pattern-based recommendations for common conflicts
- No creative strategy generation
- Savings: 80% vs LLM-generated resolution strategies
6. Progressive Conflict Resolution (800 token savings)
Pattern: Resolve one file at a time, not all at once
- Present conflicts incrementally (400 tokens per file)
- Resolve, test, then next file
- Full-batch resolution only if explicitly requested
- Savings: 65% vs all-at-once resolution
7. Grep-Based Conflict Marker Detection (400 token savings)
Pattern: Find conflict markers with Grep
- Grep for
<<<<<<<,=======,>>>>>>>(150 tokens) - Count conflicts without reading full files
- Read only files being resolved
- Savings: 75% vs reading all conflicted files
8. Cached Test Validation (500 token savings)
Pattern: Run minimal tests after resolution
- Cache test command from package.json
- Run only tests for affected files
- Skip full test suite unless requested
- Savings: 70% vs full test suite runs
Real-World Token Usage Distribution
Typical operation patterns:
- Check conflicts (no conflicts): 80 tokens
- Analyze conflicts (5 files): 1,800 tokens
- Resolve conflicts (one file at a time): 1,200 tokens per file
- Full resolution (all files): 3,000 tokens
- Auto-resolve (strategy: ours/theirs): 800 tokens
- Most common: Sample-based analysis or incremental resolution
Expected per-resolution: 1,500-2,500 tokens (50% reduction from 3,000-5,000 baseline) Real-world average: 1,000 tokens (due to early exit, sample analysis, incremental resolution)
Pre-Flight Checks
Before resolving conflicts, I'll verify:
- Git repository exists
- Merge/rebase in progress
- Conflicts present
- Can access conflicted files
<think>
Conflict Resolution Strategy:
- What type of conflict? (merge vs rebase)
- How many files conflicted?
- Are conflicts in code or config?
- Which strategy is safest?
- How to validate resolution?
</think>First, let me detect and analyze conflicts:
#!/bin/bash
# Detect and analyze merge conflicts
set -e
echo "=== Conflict Detection ==="
echo ""
# 1. Verify git repository
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "Error: Not a git repository"
exit 1
fi
# 2. Check if merge/rebase in progress
merge_in_progress=0
rebase_in_progress=0
if [ -f "$(git rev-parse --git-dir)/MERGE_HEAD" ]; then
merge_in_progress=1
echo "Status: Merge in progress"
elif [ -d "$(git rev-parse --git-dir)/rebase-merge" ] || [ -d "$(git rev-parse --git-dir)/rebase-apply" ]; then
rebase_in_progress=1
echo "Status: Rebase in progress"
else
echo "Status: No merge or rebase in progress"
echo ""
echo "No conflicts to resolve"
exit 0
fi
echo ""
# 3. List conflicted files
echo "Conflicted Files:"
conflicted_files=$(git diff --name-only --diff-filter=U)
if [ -z "$conflicted_files" ]; then
echo " No conflicted files found"
exit 0
fi
echo "$conflicted_files" | while read -r file; do
echo " • $file"
done
echo ""
# 4. Count conflicts
conflict_count=$(echo "$conflicted_files" | wc -l)
echo "Total Conflicts: $conflict_count"
echo ""
# 5. Categorize conflicts
echo "Conflict Categories:"
echo "$conflicted_files" | awk -F'/' '{
if ($0 ~ /test/) tests++
else if ($0 ~ /\.(md|txt)$/) docs++
else if ($0 ~ /\.(ts|js|tsx|jsx)$/) code++
else if ($0 ~ /\.(yml|yaml|json|lock)$/) config++
else if ($0 ~ /package\.json|requirements\.txt|Cargo\.toml/) deps++
else others++
}
END {
if (code) print " Code files: " code
if (config) print " Config files: " config
if (deps) print " Dependencies: " deps
if (tests) print " Test files: " tests
if (docs) print " Documentation: " docs
if (others) print " Other: " others
}'
echo ""
# 6. Show branches involved
if [ $merge_in_progress -eq 1 ]; then
echo "Merge Details:"
echo " Current: $(git branch --show-current)"
echo " Merging: $(git rev-parse --abbrev-ref MERGE_HEAD)"
elif [ $rebase_in_progress -eq 1 ]; then
echo "Rebase Details:"
echo " Onto: $(cat "$(git rev-parse --git-dir)/rebase-merge/onto" 2>/dev/null || echo "unknown")"
fi
echo ""Phase 1: Analyze Conflict Type
Understand the nature of each conflict:
#!/bin/bash
# Analyze conflict complexity
analyze_conflict() {
local file="$1"
echo "=== Analyzing: $file ==="
echo ""
# 1. Count conflict markers
conflict_sections=$(grep -c "^<<<<<<< " "$file" 2>/dev/null || echo "0")
echo "Conflict Sections: $conflict_sections"
echo ""
# 2. Show conflict context
echo "Conflicts in $file:"
echo "----------------------------------------"
# Extract and display each conflict
awk '
/^<<<<<<< / { in_conflict=1; ours="" }
/^=======/ { in_ours=0; in_theirs=1 }
/^>>>>>>> / {
in_conflict=0
in_theirs=0
conflicts++
print ""
next
}
in_conflict && !in_theirs {
if ($0 !~ /^<<<<<<< /) ours = ours $0 "\n"
}
in_theirs {
if ($0 !~ /^=======/ && $0 !~ /^>>>>>>> /) {
print "OURS (" conflicts+1 "):"
print ours
print "THEIRS (" conflicts+1 "):"
print $0
while (getline > 0 && $0 !~ /^>>>>>>> /) {
if ($0 !~ /^=======/) print $0
}
print "---"
}
}
' "$file"
echo "----------------------------------------"
echo ""
# 3. Detect conflict type
if grep -q "package.json\|package-lock.json\|yarn.lock" <<< "$file"; then
echo "Type: Dependency conflict"
echo "Strategy: Accept theirs, then reinstall"
elif grep -q "\.md$\|\.txt$\|README" <<< "$file"; then
echo "Type: Documentation conflict"
echo "Strategy: Manual merge (both changes likely valid)"
elif grep -q "test" <<< "$file"; then
echo "Type: Test conflict"
echo "Strategy: Keep both, ensure tests pass"
else
echo "Type: Code conflict"
echo "Strategy: Semantic analysis required"
fi
echo ""
}
# Analyze first conflicted file
first_conflict=$(echo "$conflicted_files" | head -1)
analyze_conflict "$first_conflict"Phase 2: Strategy Recommendation
Recommend the best resolution strategy:
Now I'll recommend a resolution strategy:
#!/bin/bash
# Recommend resolution strategy
recommend_strategy() {
local file="$1"
echo "=== Resolution Strategy ==="
echo ""
# Analyze file content
file_type=$(basename "$file")
# Strategy matrix
case "$file" in
package.json|package-lock.json|yarn.lock|Gemfile.lock|Cargo.lock)
echo "Recommended: Accept THEIRS + Reinstall"
echo "Reason: Dependency locks should be regenerated"
echo ""
echo "Steps:"
echo " 1. git checkout --theirs $file"
echo " 2. npm install / bundle install / cargo build"
echo " 3. git add $file"
strategy="theirs-reinstall"
;;
*.md|*.txt|README*|CHANGELOG*)
echo "Recommended: MANUAL merge"
echo "Reason: Documentation - both changes likely valid"
echo ""
echo "Steps:"
echo " 1. Edit file manually"
echo " 2. Combine both versions"
echo " 3. Remove conflict markers"
echo " 4. git add $file"
strategy="manual"
;;
*test*|*spec*)
echo "Recommended: Keep BOTH + Validate"
echo "Reason: Tests - both may be needed"
echo ""
echo "Steps:"
echo " 1. Merge both test cases"
echo " 2. Ensure tests run"
echo " 3. git add $file"
strategy="both"
;;
*.json|*.yml|*.yaml|*.toml)
echo "Recommended: MANUAL with validation"
echo "Reason: Config files - semantic meaning important"
echo ""
echo "Steps:"
echo " 1. Edit carefully"
echo " 2. Validate syntax"
echo " 3. git add $file"
strategy="manual-validate"
;;
*)
echo "Recommended: SEMANTIC analysis"
echo "Reason: Code conflict - need to understand both changes"
echo ""
echo "I'll analyze both versions..."
strategy="semantic"
;;
esac
echo ""
echo "Strategy: $strategy"
}
recommend_strategy "$first_conflict"Phase 3: Semantic Analysis
For code conflicts, analyze both versions:
For code conflicts, I'll perform semantic analysis:
#!/bin/bash
# Semantic conflict analysis
semantic_analysis() {
local file="$1"
echo "=== Semantic Analysis ==="
echo ""
# Extract OURS version
echo "Extracting versions..."
git show :2:"$file" > "/tmp/conflict-ours.tmp" 2>/dev/null || true
git show :3:"$file" > "/tmp/conflict-theirs.tmp" 2>/dev/null || true
# Compare versions
echo "Version Comparison:"
echo ""
echo "OURS (current branch):"
echo "----------------------------------------"
head -20 "/tmp/conflict-ours.tmp" || echo "Cannot extract OURS"
echo "----------------------------------------"
echo ""
echo "THEIRS (incoming changes):"
echo "----------------------------------------"
head -20 "/tmp/conflict-theirs.tmp" || echo "Cannot extract THEIRS"
echo "----------------------------------------"
echo ""
# Analyze differences
echo "Key Differences:"
diff -u "/tmp/conflict-ours.tmp" "/tmp/conflict-theirs.tmp" | head -30 || true
echo ""
# Cleanup
rm -f "/tmp/conflict-ours.tmp" "/tmp/conflict-theirs.tmp"
}
if [ "$strategy" = "semantic" ]; then
semantic_analysis "$first_conflict"
fiPhase 4: Interactive Resolution
Guide through manual resolution:
I'll guide you through resolving this conflict:
Option 1: Accept OURS (current branch)
git checkout --ours <file>
git add <file>Option 2: Accept THEIRS (incoming changes)
git checkout --theirs <file>
git add <file>Option 3: Manual Edit
- I'll open the file for you to edit
- Look for conflict markers:
<<<<<<< HEAD (ours) your changes ======= their changes >>>>>>> branch-name (theirs) - Edit to combine both or choose one
- Remove ALL conflict markers
- Save the file
Option 4: Use Merge Tool
git mergetoolLet me help you resolve this step by step:
#!/bin/bash
# Interactive conflict resolution
resolve_interactive() {
local file="$1"
local strategy="${2:-ask}"
echo "=== Resolving: $file ==="
echo ""
if [ "$strategy" = "ours" ]; then
echo "Accepting OURS (current branch)..."
git checkout --ours "$file"
git add "$file"
echo "✓ Resolved with OURS"
elif [ "$strategy" = "theirs" ]; then
echo "Accepting THEIRS (incoming changes)..."
git checkout --theirs "$file"
git add "$file"
echo "✓ Resolved with THEIRS"
elif [ "$strategy" = "manual" ]; then
echo "Opening file for manual edit..."
echo ""
echo "Conflict markers to remove:"
echo " <<<<<<< HEAD"
echo " ======="
echo " >>>>>>> branch-name"
echo ""
# Show conflict sections
grep -n -A3 -B3 "^<<<<<<< \|^=======\|^>>>>>>> " "$file" | head -30
echo ""
echo "After editing:"
echo " 1. Save file"
echo " 2. Verify no conflict markers remain"
echo " 3. Run: git add $file"
elif [ "$strategy" = "ask" ]; then
echo "Choose resolution:"
echo " 1. Accept OURS (current branch)"
echo " 2. Accept THEIRS (incoming changes)"
echo " 3. Manual edit"
echo " 4. Show diff"
echo " 5. Skip this file"
echo ""
read -p "Selection [1-5]: " choice
case $choice in
1) resolve_interactive "$file" "ours" ;;
2) resolve_interactive "$file" "theirs" ;;
3) resolve_interactive "$file" "manual" ;;
4)
git diff "$file"
resolve_interactive "$file" "ask"
;;
5) echo "Skipped: $file" ;;
*) echo "Invalid choice"; resolve_interactive "$file" "ask" ;;
esac
fi
}
# Resolve each conflicted file
echo "$conflicted_files" | while read -r file; do
resolve_interactive "$file" "${ARGUMENTS}"
echo ""
donePhase 5: Validation
Validate conflict resolution:
#!/bin/bash
# Validate conflict resolution
validate_resolution() {
echo "=== Validation ==="
echo ""
# 1. Check for remaining conflict markers
echo "1. Checking for conflict markers..."
if git diff --check 2>&1 | grep -q "conflict"; then
echo " ⚠ Conflict markers still present"
git diff --check
return 1
else
echo " ✓ No conflict markers"
fi
echo ""
# 2. Check if all conflicts resolved
echo "2. Checking for unresolved conflicts..."
unresolved=$(git diff --name-only --diff-filter=U)
if [ -n "$unresolved" ]; then
echo " ⚠ Unresolved conflicts:"
echo "$unresolved"
return 1
else
echo " ✓ All conflicts resolved"
fi
echo ""
# 3. Validate file syntax
echo "3. Syntax validation..."
for file in $(git diff --name-only --cached); do
case "$file" in
*.json)
if command -v jq > /dev/null 2>&1; then
if jq empty "$file" 2>/dev/null; then
echo " ✓ $file - valid JSON"
else
echo " ✗ $file - invalid JSON"
return 1
fi
fi
;;
*.yml|*.yaml)
if command -v yamllint > /dev/null 2>&1; then
if yamllint "$file" 2>/dev/null; then
echo " ✓ $file - valid YAML"
else
echo " ⚠ $file - YAML warnings"
fi
fi
;;
package.json)
if command -v npm > /dev/null 2>&1; then
if npm install --package-lock-only 2>/dev/null; then
echo " ✓ package.json - dependencies valid"
else
echo " ✗ package.json - dependency issues"
return 1
fi
fi
;;
esac
done
echo ""
# 4. Build check
echo "4. Build verification..."
if [ -f "package.json" ] && grep -q "\"build\":" package.json; then
if npm run build > /dev/null 2>&1; then
echo " ✓ Build successful"
else
echo " ⚠ Build failed"
echo " Review resolved files"
return 1
fi
else
echo " ⓘ No build command found"
fi
echo ""
# 5. Test check
echo "5. Test verification..."
if [ -f "package.json" ] && grep -q "\"test\":" package.json; then
echo " Running tests..."
if npm test 2>&1 | tail -10; then
echo " ✓ Tests passing"
else
echo " ⚠ Tests failing"
echo " Conflict resolution may need adjustment"
return 1
fi
else
echo " ⓘ No test command found"
fi
echo ""
echo "✓ All validations passed"
return 0
}
validate_resolutionPhase 6: Complete Resolution
Finalize the merge/rebase:
#!/bin/bash
# Complete merge or rebase
complete_resolution() {
echo "=== Complete Resolution ==="
echo ""
# Check resolution type
if [ -f "$(git rev-parse --git-dir)/MERGE_HEAD" ]; then
echo "Completing merge..."
# Show what will be committed
echo "Changes to commit:"
git diff --cached --stat
echo ""
# Generate merge commit message
merge_msg="Merge branch '$(git rev-parse --abbrev-ref MERGE_HEAD)'"
echo "Committing merge..."
git commit -m "$merge_msg" || git commit --no-edit
echo "✓ Merge complete"
elif [ -d "$(git rev-parse --git-dir)/rebase-merge" ] || [ -d "$(git rev-parse --git-dir)/rebase-apply" ]; then
echo "Continuing rebase..."
# Continue rebase
git rebase --continue
echo "✓ Rebase continued"
echo ""
echo "If more conflicts exist, run /conflict-resolve again"
else
echo "No merge or rebase in progress"
fi
}
if validate_resolution; then
complete_resolution
else
echo "⚠ Validation failed"
echo "Fix issues before completing resolution"
exit 1
fiConflict Resolution Patterns
Common Scenarios:
1. Package Lock Conflicts:
/conflict-resolve theirs
npm install # Regenerate lock
git add package-lock.json2. Documentation Conflicts:
/conflict-resolve manual
# Edit file to combine both versions
git add README.md3. Code Conflicts:
/conflict-resolve
# Analyze semantic differences
# Choose appropriate strategy
# Validate with tests4. Config Conflicts:
/conflict-resolve manual
# Carefully merge configurations
# Validate syntax
git add config.ymlIntegration with Other Skills
Complete Workflow:
# 1. Conflict detected during merge/rebase
git merge feature-branch # Conflicts!
# 2. Resolve conflicts
/conflict-resolve
# 3. Validate with tests
/test
# 4. Complete merge
git commit
# Or during branch-finish
/branch-finish # May trigger conflict-resolveAdvanced Strategies
Three-Way Merge:
# Show base, ours, and theirs
git show :1:file # Base (common ancestor)
git show :2:file # Ours (current branch)
git show :3:file # Theirs (incoming)Merge Tool Integration:
# Configure merge tool
git config merge.tool vimdiff
# Use during resolution
git mergetool <file>Abort Options:
# Abort merge
git merge --abort
# Abort rebase
git rebase --abort
# Restore original state
git reset --hard ORIG_HEADSafety Mechanisms
Before Resolution:
- Verify git state
- List all conflicts
- Analyze conflict types
- Recommend strategies
During Resolution:
- Validate syntax
- Check for conflict markers
- Verify file integrity
- Test after each resolution
After Resolution:
- Run test suite
- Verify build succeeds
- Check no markers remain
- Confirm all files resolved
Error Handling
If resolution fails:
- I'll explain the error clearly
- Show remaining conflicts
- Provide abort options
- Suggest next steps
Common Errors:
- Markers remain: Edit file completely
- Syntax invalid: Validate JSON/YAML
- Tests fail: Review resolution logic
- Build fails: Check dependencies
What I'll Actually Do
- Detect Conflicts - Identify all conflicted files
- Analyze Type - Understand nature of conflicts
- Recommend Strategy - Suggest best approach
- Guide Resolution - Step-by-step assistance
- Validate - Syntax, build, tests
- Complete - Finish merge/rebase
- Test - Integration with
/testskill
Important: I will NEVER:
- Auto-resolve without analysis
- Skip validation
- Ignore test failures
- Leave conflict markers
- Complete invalid resolutions
- Add AI attribution
Conflict resolution will be safe, validated, and thorough.
Credits: Conflict resolution strategies based on Git best practices, semantic merge techniques, and safe validation workflows.
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
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.

