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