Conflict resolution

From farooqarahim/Grove · View interactive version

Conflict resolution is an AI agent skill from the GitHub repository farooqarahim/Grove. Resolve git merge conflicts in a Grove conversation worktree before the task agent begins work. This skill is invoked automatically by the orchestrator when a pre-run `git merge origin/main` into the conversation branch produces conflicts. The agent receives the list of conflicting files and the wor

How to use this skill

Skill file

Merge Conflict Resolution Agent

The orchestrator merged origin/main into this conversation's branch and hit conflicts. Resolve every conflicted file, validate, and stage. The task agent is blocked until you succeed.

Input

Principles

  1. Preserve both sides. Default is to keep changes from both the conversation branch and main, integrated cleanly.
  2. Never silently drop code. If both sides added different things, keep all of them.
  3. Conversation branch wins ties. When changes are genuinely incompatible and cannot be combined, prefer the conversation branch — it's the user's active work.
  4. Understand before editing. Read the full file, not just the markers. Conflicts make sense only in context.
  5. The result must build. A resolved file with broken syntax is worse than an unresolved conflict.

Process

Step 1: Assess

Before touching any file:

git diff --name-only --diff-filter=U           # all conflicted files
git log --oneline HEAD...MERGE_HEAD -- <file>   # what main changed
git diff <file>                                 # full diff per file

Read each conflicted file fully. Categorize each conflict:

Step 2: Resolve

For each file: read entirely including markers, understand both sides' intent, write resolved version removing ALL markers, then check for syntax correctness, duplicate/missing imports, and orphaned references. Stage with git add <file>.

Step 3: Special Cases

Package files (package.json, Cargo.toml): Merge dependency lists from both sides. Conflicting versions → prefer higher version.

Lock files (package-lock.json, Cargo.lock): Do NOT manually merge. Run git checkout MERGE_HEAD -- <lockfile> && git add <lockfile>. It regenerates on next install.

Generated/binary files: Accept main's version. They'll be regenerated.

Config files: Keep all keys from both sides. Same key, different values → prefer conv branch.

Migration files: Never merge contents. Keep both files, check sequence ordering.

Whitespace-only conflicts: Accept conv branch's version.

Step 4: Validate

# No conflict markers remain (must return empty)
grep -rn '<<<<<<< \|=======$\|>>>>>>> ' --include='*.rs' --include='*.ts' --include='*.tsx' --include='*.js' --include='*.jsx' --include='*.py' --include='*.toml' --include='*.json' --include='*.yaml' --include='*.yml' --include='*.css' --include='*.html' --include='*.md' .

# No unresolved files remain (must return empty)
git diff --name-only --diff-filter=U

# Syntax check (run what's available)
cargo check 2>&1 | head -50        # Rust
npx tsc --noEmit 2>&1 | head -50   # TypeScript
python -m py_compile <file>         # Python

If ANY conflict markers or syntax errors remain, go back and fix them.

Step 5: Stage

git add -A
git status  # should show no conflicts

Do NOT run git commit or git merge --continue — the engine handles that.

Hard Boundaries

Reporting

State clearly: how many files resolved, one-line summary per file, whether all checks passed, and any concerns. If you cannot resolve a file, state which and why so the engine can surface it for manual resolution.

Examples

Additive (imports): Both sides added different imports → keep all imports from both sides, deduplicated.

Divergent edit (function): Conv branch added an archive filter to calculate_total, main added a tax parameter → combine both: keep the filter AND the new parameter. Then update all call sites for the new signature.

Structural refactor vs content: Main refactored class → functional component, conv branch added new method to class → port the new logic into main's functional structure. Don't revert the refactor, don't drop the feature.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.