DEV Community

brian austin
brian austin

Posted on

How I use Claude Code to resolve merge conflicts — a complete workflow

How I use Claude Code to resolve merge conflicts — a complete workflow

Merge conflicts are one of the most stressful moments in software development. You're in the middle of a deployment window, your branch is diverged, and you've got 47 conflicted files staring at you.

Here's the exact workflow I use with Claude Code to get through it without breaking anything.

The problem with merge conflicts

Traditional merge conflict resolution is tedious:

  • You open each file, read both versions
  • You guess at intent based on the code
  • You make a decision that might be wrong
  • You repeat 47 more times

With large PRs and fast-moving codebases, this takes hours. And by hour 3, you're making mistakes.

Starting with context

The key insight: Claude Code needs to understand WHY both sides made their changes before it can recommend the right resolution.

# Before touching a single conflict, give Claude the full picture
claude "Read these two branches:
- main: recent refactor of the auth module (last 3 commits)
- feature/oauth: adds OAuth2 login flow

Summarize what each side was trying to accomplish before I start resolving conflicts."
Enter fullscreen mode Exit fullscreen mode

This takes 2 minutes and saves 20. Now Claude understands intent, not just syntax.

Triaging by conflict type

Not all conflicts are equal. I sort them first:

# Get a bird's eye view of what's conflicted
git diff --name-only --diff-filter=U | head -30

# Ask Claude to categorize them
claude "Here are 47 conflicted files. Categorize each as:
1. TRIVIAL (formatting, imports, whitespace)
2. LOGIC (actual behavior changes)
3. DANGEROUS (auth, payments, data integrity)

List each file and its category."
Enter fullscreen mode Exit fullscreen mode

Now I know to do TRIVIAL conflicts automatically and focus human attention on DANGEROUS ones.

Resolving by category

Trivial conflicts (automated)

claude "Resolve all import ordering and formatting conflicts in these files automatically:
[paste list of trivial files]

Use the feature branch version for new imports, main branch for any existing ones that were reorganized."
Enter fullscreen mode Exit fullscreen mode

Logic conflicts (with explanation)

claude "For auth/session.js:
- Show me what the main branch was trying to do
- Show me what the feature branch was trying to do  
- Recommend a resolution that preserves both intents
- If they're incompatible, tell me clearly so I can make the call"
Enter fullscreen mode Exit fullscreen mode

Dangerous conflicts (human decision)

For payments, auth tokens, data migrations — I always make the final call. Claude prepares the options, I decide:

claude "For payments/stripe.js conflict:
- What does the main branch version do?
- What does the feature branch version do?
- What are the risks of choosing wrong?
- Do NOT auto-resolve this. Give me a clear recommendation with reasoning."
Enter fullscreen mode Exit fullscreen mode

The rate limit problem

Here's what actually happens on large merge conflicts:

You start the session, Claude helps with 10 files. Then you hit the rate limit. You wait, come back, and Claude has lost context. You re-explain the whole branch history. You hit the rate limit again.

For a 47-file conflict, this is brutal.

The fix: I use SimplyLouie as my API backend. It's $2/month and removes the rate limits entirely. I can run through all 47 files in one continuous session without interruption.

# Set your API endpoint once in .claude/settings.json
# Then run the entire conflict resolution as one continuous session
claude "We need to resolve all 47 conflicts in the oauth-merge branch.
Start with trivial, move to logic, flag dangerous for my review.
Do not stop until all non-dangerous conflicts are resolved."
Enter fullscreen mode Exit fullscreen mode

No interruptions. No re-explaining context. The session runs start to finish.

Verification before merge

After resolving conflicts, always verify:

# Make sure tests still pass after resolution
claude "Run the test suite and explain any failures.
For each failure, tell me if it's likely from the merge resolution or pre-existing."

# Check for logic errors introduced during resolution
claude "Review the resolved files in auth/ and payments/ for any logic inconsistencies.
Look specifically for: mismatched variable names, missing imports, broken error handling."
Enter fullscreen mode Exit fullscreen mode

The complete command sequence

# 1. Context gathering (2 min)
git log main..feature --oneline
git log feature..main --oneline
claude "Summarize the intent of both branches"

# 2. Triage (3 min)
git diff --name-only --diff-filter=U > conflicts.txt
claude "Categorize conflicts.txt as TRIVIAL/LOGIC/DANGEROUS"

# 3. Automated resolution of trivial conflicts
claude "Auto-resolve all TRIVIAL conflicts in the list"

# 4. Logic conflicts with guidance
for each LOGIC file:
  claude "Explain both sides and recommend resolution for [file]"

# 5. Human review of DANGEROUS conflicts
for each DANGEROUS file:
  claude "Prepare options for [file] — I will decide"

# 6. Verification
claude "Run tests and check for logic errors in resolved files"
Enter fullscreen mode Exit fullscreen mode

Results

Before this workflow: 47-file merge conflict = 4-6 hours, high anxiety, usually some regressions.

After: 45-90 minutes, systematic, rare regressions.

The biggest gain isn't speed — it's confidence. When you understand why both sides made their changes, your resolutions are correct instead of guessed.


If you use Claude Code heavily and hit rate limits during long merge sessions, check out SimplyLouie — $2/month API that keeps your sessions running continuously.

What's your merge conflict workflow? Share in the comments.

Top comments (0)