Skip to navigation

Claude Code Merge Conflicts: Resolve Behavior, Not Lines

In short: Compare both intents, rerun focused tests, and document semantic choices instead of accepting whichever side compiles.

Published 18 min read
On this page

Direct answer

A conflict marker tells you that two sides changed the same region. It says nothing about which behavior the finished code should have. Resolve a conflict by naming both intents, writing the combined behavior in one sentence, and proving that sentence with a focused test. Accepting whichever side compiles is how a working feature disappears while every check stays green.

The method takes minutes and prevents a class of bug that review usually misses. Claude Code can describe what each side intended, but the decision about combined behavior belongs to the engineer. Compile success is not the goal; preserved behavior is.

Evidence map linking a conflict hunk to each side's intent, the combined behavior, and the focused test that checks it.
Editorial evidence map based on F058, F059, and F060. It organizes the resolution method; it is not an automatic conflict-resolution feature.

Why line-level resolution breaks products

Git resolves conflicts at the text level because that is what it tracks. The tool has no model of what a validation rule means, why a guard clause exists, or whether two features were supposed to coexist. When both sides change the same lines, the marker is a request for a human decision about behavior.

The familiar shortcuts all skip that decision. “Take theirs” keeps the incoming side and drops the local change. “Take mine” does the reverse. An auto-merge tool may pick a side when the text happens to combine. Each option can produce code that builds, passes a broad suite, and silently removes a feature someone shipped last week.

Claude Code raises the tempo of these situations because it produces branches quickly. Two agents, or an agent and a human, can modify the same function in parallel within an afternoon. The conflict arrives with less accumulated context than a human-vs-human merge usually has, so the missing intent is easier to miss.

The cost shows up later. A behavior that vanished during a merge surfaces as a support ticket, a regression test written after the fact, or a re-implementation of something that already existed. None of those are cheap.

Identify both conflicting intents

Start by reading each side as a change with a purpose, not as a set of lines. Git provides the raw material: the merge documentation describes conflict resolution as part of combining histories, and commands like git log and git show expose what each side actually did.

Official, F058: Git’s rebase documentation describes conflict resolution as part of replaying commits. The documentation does not prescribe domain-specific conflict choices, which is exactly why the semantic step stays with the engineer.

A practical reading pass has three questions. What did the incoming side change? What did the local side change? Did either side remove something the other relies on? Ask Claude Code to summarize each side’s diff in plain language. A summary such as “incoming adds a retry with exponential backoff; local adds a circuit breaker around the same call” gives you the two intents in one screen.

Write the two intents down before editing anything. The written form is what you compare the final resolution against.

Conflict hunk Side A intent Side B intent Combined behavior to write down
Retry configuration Add exponential backoff Add a circuit breaker before retry Breaker opens first; retries use backoff while closed
Validation message Localize the message Add a field name to the message Localized message that includes the field name
Feature flag check Rename the flag Add a second flag condition Both flags evaluated with the new name
Test setup Add a fixture for user B Add a fixture for user C Both fixtures coexist in setup
Removed guard clause Delete an obsolete check Rely on that check elsewhere Reconcile before accepting the removal

The last row is the dangerous one. A removal on one side and a dependency on the other is a semantic conflict that no text merge can resolve correctly on its own.

Workflow from reading both conflicting intents to writing combined behavior, resolving the smallest region, and running focused checks.
Editorial workflow based on F058 and F060. The sequence is a review discipline, not a Claude Code built-in feature.

Read the surrounding code and tests

A hunk sits inside a function, which sits inside a module, which has tests. Reading the surroundings is how you find out whether the two intents are actually compatible.

Look for three things. First, callers of the changed code, because a signature change on one side may break a caller the conflict did not show. Second, tests that cover the region, because they encode the behavior someone cared enough to protect. Third, comments or documentation that explain why the code looks the way it does.

Claude Code is useful here as a reader. Ask for the callers of a function and the tests that exercise it. Ask which tests would fail if a specific branch were removed. The answers are starting points for your own reading, not verdicts.

A test that one side added and the other side’s change would break is a strong signal. That test encodes intent in executable form. Resolving the conflict by deleting the test is resolving the disagreement by silencing the witness.

Write the combined behavior before editing

One sentence is enough. “When the breaker is closed, retries use exponential backoff; when the breaker is open, calls fail fast” is a combined behavior statement. It names both features and their interaction.

The sentence does three jobs. It forces you to decide whether both features survive. It gives the reviewer something specific to check. It gives you a target for the focused test you are about to write or run.

Derived, F060: Writing the combined intended behavior before editing the conflict, then verifying it with focused checks, is a review method derived from the merge workflow. It is not an automatic feature, and it does not replace the project’s normal verification.

If you cannot write the sentence, you do not yet understand one of the two sides. That is the moment to stop and read more, or to ask the author of the unclear side. Guessing at this point produces a resolution that looks finished.

Resolution choice Alternative rejected Focused test Reviewer
Breaker gates the retry loop Retry without the breaker Breaker-open rejects immediately Reliability owner
Localized message includes field name Keep the English-only message Message renders in the test locale Frontend owner
Both flags evaluated Drop the older flag Flag combination matrix test Platform owner
Removed guard re-added Accept the deletion Regression test for the guarded path Original guard author

Resolve the smallest conflicted region first

Large conflicts are easier to resolve one hunk at a time, starting with the hunk whose behavior is clearest. Each resolution can change the context of the next hunk, so working from the well-understood case toward the murky one keeps the decisions grounded.

Claude Code can apply a resolution to a single hunk when you have already decided the combined behavior. The order matters: decide first, then edit. Reversing that order produces edits that look decisive and mean nothing.

A region that cannot be resolved without guessing is a signal to bring in the other author. A five-minute conversation resolves ambiguity that an hour of editing only hides.

Check for deleted tests and guards

The most damaging resolutions are the ones that make a conflict disappear by removing a protection. A deleted test does not fail. A removed guard clause does not warn. Both look like progress in the diff.

Before completing the merge, list the tests and assertions that existed before the operation and compare with the list after. Git log and git show make the before-state available. Ask Claude Code to produce the comparison: which test names were present on each side, and which appear in the result?

Deleted or changed guard Test coverage after resolution Residual risk Owner to notify
Null check removed by side A No test covered it Null path unhandled Module owner
Validation rule dropped by side B Validation suite covers other fields One field accepts invalid input API owner
Test deleted to clear a conflict Test no longer exists Behavior unverified QA contact
Assertion weakened Test still runs Softer guarantee than intended Test author

Any row in that table is a decision to record, not a detail to absorb silently. A resolution that removes coverage should say so in the merge commit or pull request description, with the reason and the follow-up.

Run focused behavioral checks

A focused check targets the behavior you just wrote down. A broad suite is still necessary before the merge lands, but it is the wrong first tool because it produces noise and can pass while the specific interaction is broken.

Official, F059: Claude Code best practices recommends providing a pass-or-fail check for completed work. Focused tests can check the chosen behavior, but they cannot prove all merged behavior is correct.

Pick the test closest to the combined behavior. For a retry and breaker interaction, that is the test that exercises the breaker around the retry path. For a validation message, it is the test that renders the message. Jest and similar runners let you target a single file or a name pattern, which keeps the loop fast.

If no test covers the combined behavior, write one. A small test that would have failed under the wrong resolution is worth more than any amount of reading. Keep it after the merge; it is the regression guard for the decision you made.

Ask Claude Code to explain the semantic choice

Once the resolution is drafted, a second pass catches the decisions made by reflex. Ask Claude Code to read the resolved region and describe what behavior it now implements, in plain language, without looking at your intent note first.

Compare the description with your written combined behavior. If they differ, either the edit did not express the decision or the decision was never as clear as the note suggested. Both are useful findings.

A second useful prompt: “which tests in this repository would fail if this behavior were removed?” The answer identifies the witnesses to the resolution. If the list is empty, the behavior is unprotected regardless of how correct it looks.

The agent is a reader and a describer here. The decision about which behavior the product should have stays with the engineer, because the agent has no access to the product intent behind either side.

Record the resolution rationale

Future readers will ask why the code looks the way it does. A merge commit that says “resolved conflicts” tells them nothing. A merge commit that says “kept the breaker ahead of retries so open circuits fail fast, per the retry owner” answers the question.

Record the rationale where the next engineer will find it. The merge commit message works. A comment at the resolution site works for behavior that is not obvious from the code. The pull request description works for the overall merge.

Recorded decision Where it lives Who benefits later
Why the breaker precedes the retry Merge commit message Anyone reading history
Why a guard was re-added Inline comment at the guard Future editors of the function
Why a test was restored Pull request description Reviewer and QA
Why a feature flag was kept Flag registry note Platform and product owners

Keep incident details, customer names, and secrets out of these records. A merge message is public history in most repositories.

Tradeoff between the time spent writing combined behavior and the reduced risk of silently dropping a feature during a merge.
Editorial tradeoff diagram based on F058 through F060. The extra minutes produce a decision record; they do not guarantee the merged system is fully correct.

Worked example: retry meets circuit breaker

Suppose a pull request adds exponential backoff to an HTTP client. Meanwhile, main has gained a circuit breaker around the same client. Both changes touch the request method, and the merge produces three conflict markers.

The reading pass finds the intents. Side A wraps the request in a loop with increasing delays. Side B wraps the request in a breaker that opens after consecutive failures. The interaction question is ordering: does the breaker see each retry attempt, or only the first?

The combined behavior statement: “while the breaker is closed, each attempt may retry with backoff; failures inside the retry loop count toward opening the breaker; an open breaker rejects immediately without retrying.”

The resolution keeps the breaker outside the retry loop and passes failure counts from the loop back to the breaker. A focused test exercises the new arrangement: breaker closed, two failures, breaker opens, next call rejects without delay. The test passes under the resolution and would fail under a naive “take theirs” that dropped the counting.

Derived arithmetic for the example: The conflict had 3 markers. Two were ordering questions with clear answers from the combined-behavior statement. One was a removed assertion on side B that side A’s test relied on, re-added during resolution. Markers resolved by decision: 3 of 3. Markers resolved by auto-accept: 0. This arithmetic tracks the discipline; it is not a benchmark.

The concrete win is a merge that preserves both features and adds a regression test for their interaction. The concrete loss is that the example required knowledge of both features’ intent, which came from reading code and, in a real case, would often require asking an author. The method does not work when neither intent can be recovered.

Control checklist covering intent reading, combined behavior statement, deleted-guard check, and focused verification.
Editorial control checklist derived from F058 through F060. Passing the checklist improves the resolution; it does not prove the whole merge is behaviorally complete.

Practical checklist and runbook

  1. Read both sides as changes with purposes, using git log and git show for the raw history.
  2. Write each intent in one line before touching the conflict.
  3. Read the callers and tests around the conflicted region.
  4. Write the combined behavior as a single sentence.
  5. Resolve the smallest clear hunk first, deciding before editing.
  6. List tests and guards removed by either side, and restore or justify each removal.
  7. Run a focused test for the combined behavior; write one if it does not exist.
  8. Ask Claude Code to describe the resolved behavior and compare with the note.
  9. Record the rationale in the merge commit or pull request.
  10. Run the required checks before the merge lands.

Do not use reset with the hard flag as conflict recovery. It discards the merge state and any resolution work. Aborting the merge and starting over is the recoverable path, and the destructive git-reset guardrails post covers why the hard variant is the last resort rather than the tool of habit.

Verdict that resolving conflicts by behavior with focused tests is more reliable than accepting whichever side compiles.
Editorial verdict based on F058 through F060. The benefit is preserved intent; the honest limit is that a focused test covers the chosen interaction, not every merged behavior.

Concrete win, honest loss, and practical implication

Win: The merge keeps both features and documents why their interaction is arranged the way it is. A regression test now exists for an interaction that no test covered before, and the reviewer has a sentence to check the resolution against.

Loss: The method depends on being able to recover both intents. When the other side’s author is gone and the code has no tests or comments, the combined behavior statement becomes an inference rather than a fact. The focused test proves the chosen arrangement, not that the original intent was correctly reconstructed.

Implication: For any conflict in code with product behavior, spend the minutes on the intent pass. For a conflict in generated files, lock files, or formatting-only changes, the mechanical resolution is usually fine. Knowing which kind of conflict you are in is most of the judgment.

Where this connects in the batch

The resolution discipline applies during a replay as well as a merge. Choosing merge or rebase from the branch policy covers the decision about which operation to run before any conflict appears.

The commit you produce after resolving should be reviewable on its own. Making changes revertible with atomic commits covers that structure, and encoding change intent in commit messages covers the message that records the rationale.

When the resolved branch reaches continuous integration, recovering failed merge-queue groups covers the next failure mode. Defining merge checks with branch protection covers the settings that decide whether the resolution can land at all.

For the general trap of green checks hiding a behavioral miss, the false success from passing tests post is the wider warning. Generated tests and oracle bias covers the case where the test was written to match the code rather than the intent.

The six posts in this batch form one sequence. Choosing merge or rebase from the branch policy covers the operation that produces many conflicts. Making changes revertible with atomic commits covers the commit structure after resolution. Encoding change intent in commit messages covers the message that records the rationale. Recovering failed merge-queue groups covers the interaction failures a clean merge can still produce. Defining merge checks with branch protection covers the settings that decide whether the resolution can land.

Release and recovery topics continue in choosing a version impact with SemVer, annotated release tags, hotfix backports and cherry-picks, planning a rollback with revert, preparing a changelog from consumer-visible changes, and running a release checklist. The wider testing lane starts at selecting tests for changed code and triaging flaky tests.

Adjacent library posts that share this post’s concern for intent include generated tests and oracle bias, false success from passing tests, verification done proof, legacy code and tribal knowledge, overengineering large diffs, the code review bottleneck, destructive git-reset guardrails, and database migration safety. For conflicts that involve a schema, database migration safety is the direct companion. Estimating monthly LLM API cost covers the spend side of long diagnosis sessions.

Data gap and future update

The research packet contains no measured defect rate for line-level versus behavior-level conflict resolution, no benchmark for time-to-resolve, and no reproducible community study of silent feature loss during merges. No such figure is claimed here.

The official evidence covers the mechanics of conflict resolution and the recommendation to provide a pass-or-fail check. It does not quantify how often a compile-clean merge removes behavior. A future update should add a documented case study if a public one becomes available.

Merge tooling changes over time. Recheck the cited Git and runner pages before relying on specific flags. Until stronger evidence exists, treat the intent-first method as a reviewable discipline with a known limitation: it needs recoverable intent on both sides.

One AI API Key option for OpenAI-format agents

Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The research packet records Claude IDs as unavailable on 2026-11-27.

For a separate OpenAI-format agent, One AI API Key offers https://api.oneaiapikey.com/v1, one key, and 46 live free IDs. That option concerns a different client and request format, not a workaround for Claude Code authentication. Review the free model list and eligibility details before choosing an agent route, or start from the quickstart.

FAQ

Does a conflict-free merge mean the behavior is correct?

No. Git merges text. Two sides can avoid a textual conflict while interacting badly at runtime. The focused test for the combined behavior is the evidence, not the absence of markers.

Should I accept an auto-resolution and review it later?

Review it now or not at all. An auto-resolution that drops a guard looks finished and gets forgotten. If you must defer, record the hunk and the open question in the pull request so the review cannot miss it.

Can Claude Code resolve conflicts on its own?

It can propose resolutions and apply them, and it is useful for describing what each side intended. The decision about combined behavior belongs to the engineer, because the agent has no access to the product intent behind either change.

What if resolving the conflict requires deleting a test?

Treat that as a decision to record. Explain why the test no longer applies, or replace it with one that covers the new combined behavior. A silent deletion is the failure mode this post exists to prevent.

How do I practice this on a small conflict?

Pick a conflict in a function with existing tests. Write the two intents, write the combined sentence, and check that the existing tests still pass after the resolution. The existing tests are the witnesses that your resolution preserved behavior.

More Claude Code troubleshooting

Sources

  • Official: Git merge, documenting merge and conflict resolution as part of combining histories (F060).
  • Official: Git rebase, describing conflict resolution as part of replaying commits (F058).
  • Official: Git show, supporting inspection of each side’s change.
  • Official: Git log, supporting history reads for intent recovery.
  • Official: Jest CLI options, supporting focused single-file and name-pattern test runs.
  • Official: Claude Code best practices, recommending a pass-or-fail check for completed work (F059).
  • Derived: F060 supports writing the combined behavior before editing, then verifying with focused checks.
More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
  • 100requests
    per day
  • 3Mtokens
    per day
  • 47free
    models
  • $0per
    token
  • No card
  • No end date
Claim $10 credit →