Description
The AI prompt for cherry-pick conflict resolution currently focuses only on resolving merge conflict markers. It doesn't instruct the AI to validate that the resolved code is consistent with the target branch's codebase — leading to resolutions that pass conflict resolution but fail tox and pre-commit.
This is a complementary improvement to #1159 (which adds code-level tox/pre-commit gates). Better instructions won't eliminate all failures, but can reduce how often the gate triggers.
Current Prompt
System prompt:
You are an expert software engineer. Resolve git cherry-pick merge conflicts
preserving the intent of the original commit.
User prompt:
This repository has cherry-pick merge conflicts that need to be resolved.
**Original commit:** `<hash>`
**Commit message:** <message>
**Cherry-picking onto branch:** `<branch>`
**PR title:** <title>
**Files changed in original commit:**
<diff stat>
Resolve all conflicts. The goal is to apply the original commit's changes
onto the target branch. Use the available tools to inspect the original commit
diff, read the conflicted files, and edit them to resolve conflicts.
If the original commit DELETED a file, use git_rm to remove it — do NOT empty the file content.
Available tools: read, edit, write, grep, find, ls, git_diff, git_log, git_show, git_status, git_rm
What's Missing
The prompt gives no guidance on validating the resolution against the target branch. The AI has all the tools it needs to do this (grep, find, read, git_show) — it just isn't told to.
Suggested additions to the prompt
-
Import validation: After resolving conflicts, verify that all imports in the resolved files reference modules/functions/classes that exist on the target branch. Use grep or find to confirm. If an import references something that doesn't exist on the target branch, stop and report failure — do not remove the import or the code that depends on it. This conflict requires manual resolution.
-
Function/class reference validation: If the resolved code calls functions or uses classes, verify they exist in the target branch codebase. If a referenced API doesn't exist on the target branch, stop and report failure — do not adapt, stub, or remove the code. This conflict requires manual resolution.
-
Consistent style: Read a few existing files on the target branch (same directory) to match the coding style — trailing commas, quote style, line length conventions. This reduces pre-commit formatting failures.
-
No leftover conflict markers: Verify no <<<<<<<, =======, or >>>>>>> markers remain in any resolved file.
-
Deleted vs modified files: When the target branch has significantly diverged, a file that was modified in the original commit may not need the same changes on the target branch. Compare the target branch's version of the file with the original commit's intent — don't blindly force the original diff.
What This Won't Solve
- Formatting rules enforced by pre-commit (ruff, black, isort) — the AI can't know the exact config without running the tool
- Test failures from behavioral differences between branches
- Dependency mismatches (different package versions on target branch)
These are caught by the code-level gate in #1159.
Done
Description
The AI prompt for cherry-pick conflict resolution currently focuses only on resolving merge conflict markers. It doesn't instruct the AI to validate that the resolved code is consistent with the target branch's codebase — leading to resolutions that pass conflict resolution but fail tox and pre-commit.
This is a complementary improvement to #1159 (which adds code-level tox/pre-commit gates). Better instructions won't eliminate all failures, but can reduce how often the gate triggers.
Current Prompt
System prompt:
User prompt:
Available tools:
read,edit,write,grep,find,ls,git_diff,git_log,git_show,git_status,git_rmWhat's Missing
The prompt gives no guidance on validating the resolution against the target branch. The AI has all the tools it needs to do this (
grep,find,read,git_show) — it just isn't told to.Suggested additions to the prompt
Import validation: After resolving conflicts, verify that all imports in the resolved files reference modules/functions/classes that exist on the target branch. Use
greporfindto confirm. If an import references something that doesn't exist on the target branch, stop and report failure — do not remove the import or the code that depends on it. This conflict requires manual resolution.Function/class reference validation: If the resolved code calls functions or uses classes, verify they exist in the target branch codebase. If a referenced API doesn't exist on the target branch, stop and report failure — do not adapt, stub, or remove the code. This conflict requires manual resolution.
Consistent style: Read a few existing files on the target branch (same directory) to match the coding style — trailing commas, quote style, line length conventions. This reduces pre-commit formatting failures.
No leftover conflict markers: Verify no
<<<<<<<,=======, or>>>>>>>markers remain in any resolved file.Deleted vs modified files: When the target branch has significantly diverged, a file that was modified in the original commit may not need the same changes on the target branch. Compare the target branch's version of the file with the original commit's intent — don't blindly force the original diff.
What This Won't Solve
These are caught by the code-level gate in #1159.
Done
_resolve_cherry_pick_with_ai()with target-branch validation instructions