Resolve Conflicts
Purpose
Intelligent git conflict resolution. Detects conflict type, categorizes files by resolution strategy, and resolves conflicts with awareness of both sides' intent. Handles lock files, migrations, and code conflicts differently.
Trigger
- Command:
/ai-resolve-conflicts
- Context: git operation resulted in conflicts (rebase, merge, cherry-pick, revert).
- Auto-detect:
git status shows "Unmerged paths" or "both modified".
Procedure
Detect conflict type -- determine the operation that caused conflicts:
# Check which operation is in progress
test -d .git/rebase-merge || test -d .git/rebase-apply # rebase
test -f .git/MERGE_HEAD # merge
test -f .git/CHERRY_PICK_HEAD # cherry-pick
test -f .git/REVERT_HEAD # revert
List conflicted files -- git diff --name-only --diff-filter=U
Categorize each file by resolution strategy:
| Category |
File patterns |
Strategy |
| Lock files |
*.lock, poetry.lock, Cargo.lock, package-lock.json, uv.lock |
Accept theirs, regenerate |
| Migrations |
migrations/, alembic/versions/ |
Ask user (order matters) |
| Generated |
*.min.js, *.min.css, dist/, build/ |
Accept theirs, rebuild |
| Config |
*.yml, *.toml, *.json (non-lock) |
AI merge with validation |
| Code |
everything else |
AI analysis |
Resolve by category:
Lock files: accept incoming version, then regenerate:
git checkout --theirs <lockfile>
# Then regenerate: npm install / cargo generate-lockfile / uv lock / etc.
Migrations: present both sides to user with context. Migration ordering is semantic -- never auto-resolve. Show the migration graph and ask which order to apply.
Generated files: accept theirs, rebuild from source after resolution.
Config files: read both versions, merge intelligently preserving both sides' additions. Validate result against schema if available.
Code conflicts: for each conflict hunk:
a. Read surrounding context (50 lines each side)
b. Identify intent of each change (what was the goal?)
c. Check commit messages for both sides
d. Propose resolution preserving both intents
e. If intents conflict, present options to user
Stacked PR detection -- if resolving conflicts between branches in a stack:
a. Compare base, HEAD, and incoming for similarity
b. If high overlap, likely a stacked PR rebase -- prefer incoming (later branch)
c. Warn user about potential cascade to downstream branches
Validate resolution:
- Run
git diff to review all resolutions
- Run stack-specific checks (build, lint, test)
- Present summary before continuing the operation
Continue operation:
git add <resolved-files>
git rebase --continue # or merge --continue, etc.
Common Mistakes
| Mistake |
Why it is wrong |
| Auto-resolving migration conflicts |
Migration order is semantic; wrong order corrupts data |
| Keeping both sides of a lock file |
Lock files must be regenerated from the manifest |
| Resolving without reading commit messages |
Loses context about intent |
Quick Reference
/ai-resolve-conflicts # auto-detect and resolve current conflicts
No arguments needed -- the skill reads git state directly.
$ARGUMENTS
1---2name: resolve-conflicts-23description: Use when git reports merge conflicts during rebase, merge, cherry-pick, or revert operations.4---5
6
7
8# Resolve Conflicts
9
10## Purpose
11
12Intelligent git conflict resolution. Detects conflict type, categorizes files by resolution strategy, and resolves conflicts with awareness of both sides' intent. Handles lock files, migrations, and code conflicts differently.
13
14## Trigger
15
16- Command: `/ai-resolve-conflicts`
17- Context: git operation resulted in conflicts (rebase, merge, cherry-pick, revert).
18- Auto-detect: `git status` shows "Unmerged paths" or "both modified".
19
20## Procedure
21
221. **Detect conflict type** -- determine the operation that caused conflicts:
23
24 ```bash
25 # Check which operation is in progress
26 test -d .git/rebase-merge || test -d .git/rebase-apply # rebase
27 test -f .git/MERGE_HEAD # merge
28 test -f .git/CHERRY_PICK_HEAD # cherry-pick
29 test -f .git/REVERT_HEAD # revert
30 ```
31
322. **List conflicted files** -- `git diff --name-only --diff-filter=U`
33
343. **Categorize each file** by resolution strategy:
35
36 | Category | File patterns | Strategy |
37 |----------|--------------|----------|
38 | Lock files | `*.lock`, `poetry.lock`, `Cargo.lock`, `package-lock.json`, `uv.lock` | Accept theirs, regenerate |
39 | Migrations | `migrations/`, `alembic/versions/` | Ask user (order matters) |
40 | Generated | `*.min.js`, `*.min.css`, `dist/`, `build/` | Accept theirs, rebuild |
41 | Config | `*.yml`, `*.toml`, `*.json` (non-lock) | AI merge with validation |
42 | Code | everything else | AI analysis |
43
444. **Resolve by category**:
45
46 **Lock files**: accept incoming version, then regenerate:
47 ```bash
48 git checkout --theirs <lockfile>
49 # Then regenerate: npm install / cargo generate-lockfile / uv lock / etc.
50 ```
51
52 **Migrations**: present both sides to user with context. Migration ordering is semantic -- never auto-resolve. Show the migration graph and ask which order to apply.
53
54 **Generated files**: accept theirs, rebuild from source after resolution.
55
56 **Config files**: read both versions, merge intelligently preserving both sides' additions. Validate result against schema if available.
57
58 **Code conflicts**: for each conflict hunk:
59 a. Read surrounding context (50 lines each side)
60 b. Identify intent of each change (what was the goal?)
61 c. Check commit messages for both sides
62 d. Propose resolution preserving both intents
63 e. If intents conflict, present options to user
64
655. **Stacked PR detection** -- if resolving conflicts between branches in a stack:
66 a. Compare base, HEAD, and incoming for similarity
67 b. If high overlap, likely a stacked PR rebase -- prefer incoming (later branch)
68 c. Warn user about potential cascade to downstream branches
69
706. **Validate resolution**:
71 - Run `git diff` to review all resolutions
72 - Run stack-specific checks (build, lint, test)
73 - Present summary before continuing the operation
74
757. **Continue operation**:
76 ```bash
77 git add <resolved-files>
78 git rebase --continue # or merge --continue, etc.
79 ```
80
81## Common Mistakes
82
83| Mistake | Why it is wrong |
84|---------|----------------|
85| Auto-resolving migration conflicts | Migration order is semantic; wrong order corrupts data |
86| Keeping both sides of a lock file | Lock files must be regenerated from the manifest |
87| Resolving without reading commit messages | Loses context about intent |
88
89## Quick Reference
90
91```
92/ai-resolve-conflicts # auto-detect and resolve current conflicts
93```
94
95No arguments needed -- the skill reads git state directly.
96
97$ARGUMENTS