1+ <merge_resolver_best_practices >
2+ <general_principles >
3+ <principle priority =" high" >
4+ <name >Intent-Based Resolution</name >
5+ <description >
6+ Always prioritize understanding the intent behind changes rather than
7+ just looking at the code differences. Commit messages, PR descriptions,
8+ and issue references provide crucial context.
9+ </description >
10+ <rationale >
11+ Code changes have purpose - bugfixes should be preserved, features
12+ should be integrated properly, and refactors should maintain consistency.
13+ </rationale >
14+ <example >
15+ <scenario >Conflict between a bugfix and a refactor</scenario >
16+ <good >Apply the bugfix logic within the refactored structure</good >
17+ <bad >Simply choose one side without considering both intents</bad >
18+ </example >
19+ </principle >
20+
21+ <principle priority =" high" >
22+ <name >Preserve All Valuable Changes</name >
23+ <description >
24+ When possible, combine non-conflicting changes from both sides rather
25+ than discarding one side entirely.
26+ </description >
27+ <rationale >
28+ Both sides of a conflict often contain valuable changes that can coexist
29+ if properly integrated.
30+ </rationale >
31+ </principle >
32+
33+ <principle priority =" high" >
34+ <name >Escape Conflict Markers</name >
35+ <description >
36+ When using apply_diff or search_and_replace tools, always escape merge
37+ conflict markers with backslashes to prevent parsing errors.
38+ </description >
39+ <example ><![CDATA[
40+ Correct: \<<<<<<< HEAD
41+ Wrong: <<<<<<< HEAD
42+ ]]> </example >
43+ </principle >
44+
45+ <principle priority =" medium" >
46+ <name >Consider Related Changes</name >
47+ <description >
48+ Look beyond the immediate conflict to understand related changes in
49+ tests, documentation, or dependent code.
50+ </description >
51+ <rationale >
52+ A change might seem isolated but could be part of a larger feature
53+ or fix that spans multiple files.
54+ </rationale >
55+ </principle >
56+ </general_principles >
57+
58+ <resolution_heuristics >
59+ <heuristic category =" bugfix_vs_feature" >
60+ <rule >Bugfixes generally take precedence over features</rule >
61+ <reasoning >
62+ Bugfixes address existing problems and should be preserved,
63+ while features can be reintegrated around the fix.
64+ </reasoning >
65+ </heuristic >
66+
67+ <heuristic category =" recent_vs_old" >
68+ <rule >More recent changes are often more relevant</rule >
69+ <reasoning >
70+ Recent changes likely reflect the current understanding of
71+ requirements and may supersede older implementations.
72+ </reasoning >
73+ <exception >
74+ When older changes are bugfixes or security patches that
75+ haven't been addressed in newer code.
76+ </exception >
77+ </heuristic >
78+
79+ <heuristic category =" test_updates" >
80+ <rule >Changes that include test updates are likely more complete</rule >
81+ <reasoning >
82+ Developers who update tests alongside code changes demonstrate
83+ thoroughness and understanding of the impact.
84+ </reasoning >
85+ </heuristic >
86+
87+ <heuristic category =" formatting_vs_logic" >
88+ <rule >Logic changes take precedence over formatting changes</rule >
89+ <reasoning >
90+ Formatting can be reapplied, but logic changes represent
91+ functional improvements or fixes.
92+ </reasoning >
93+ </heuristic >
94+ </resolution_heuristics >
95+
96+ <common_pitfalls >
97+ <pitfall >
98+ <description >Blindly choosing one side without analysis</description >
99+ <why_problematic >
100+ You might lose important changes or introduce regressions
101+ </why_problematic >
102+ <correct_approach >
103+ Always analyze both sides using git blame and commit history
104+ </correct_approach >
105+ </pitfall >
106+
107+ <pitfall >
108+ <description >Ignoring the PR description and context</description >
109+ <why_problematic >
110+ The PR description often explains the why behind changes,
111+ which is crucial for proper resolution
112+ </why_problematic >
113+ <correct_approach >
114+ Always fetch and read the PR information before resolving
115+ </correct_approach >
116+ </pitfall >
117+
118+ <pitfall >
119+ <description >Not validating the resolved code</description >
120+ <why_problematic >
121+ Merged code might be syntactically incorrect or introduce
122+ logical errors
123+ </why_problematic >
124+ <correct_approach >
125+ Always check for syntax errors and review the final diff
126+ </correct_approach >
127+ </pitfall >
128+
129+ <pitfall >
130+ <description >Not escaping conflict markers in diffs</description >
131+ <why_problematic >
132+ Unescaped conflict markers (<<<<<<, =======, >>>>>>) in SEARCH
133+ or REPLACE sections will be interpreted as actual diff syntax,
134+ causing the apply_diff tool to fail or produce incorrect results
135+ </why_problematic >
136+ <correct_approach >
137+ Always escape conflict markers with a backslash (\) when they
138+ appear in the content you're searching for or replacing.
139+ Example: \<<<<<<< HEAD instead of <<<<<<< HEAD
140+ </correct_approach >
141+ </pitfall >
142+ </common_pitfalls >
143+
144+ <quality_checklist >
145+ <category name =" before_resolution" >
146+ <item >Fetch PR title and description for context</item >
147+ <item >Identify all files with conflicts</item >
148+ <item >Understand the overall change being merged</item >
149+ </category >
150+
151+ <category name =" during_resolution" >
152+ <item >Run git blame on conflicting sections</item >
153+ <item >Read commit messages for intent</item >
154+ <item >Consider if changes can be combined</item >
155+ <item >Escape conflict markers in diffs</item >
156+ </category >
157+
158+ <category name =" after_resolution" >
159+ <item >Verify no conflict markers remain</item >
160+ <item >Check for syntax/compilation errors</item >
161+ <item >Review the complete diff</item >
162+ <item >Document resolution decisions</item >
163+ </category >
164+ </quality_checklist >
165+ </merge_resolver_best_practices >
0 commit comments