Resolve Conflicts
Intent-aware git conflict resolution: detect the operation, categorize files by strategy (lock, migration, generated, config, code), and resolve with awareness of both sides — never blindly accept. Use it whenever git status shows unmerged paths after a rebase, merge, cherry-pick, or revert.
/ai-resolve-conflicts # auto-detect and resolve current conflicts
Workflow
Principles: §10.1 KISS (category-routing over a single generic merge); §10.4 DRY (regenerate lock/generated files rather than hand-merge).
Detect operation 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 conflicts — git diff --name-only --diff-filter=U.
Categorize each file:
| 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 —
git checkout --theirs <lockfile>, then regenerate (npm install / cargo generate-lockfile / uv lock).
- Migrations — present both sides + migration graph; ask which order (never auto-resolve — ordering is semantic).
- Config — merge preserving both sides' additions; validate against schema if available.
- Code — per hunk: (a) read 50 lines context each side, (b) identify intent per side, (c) check commit messages, (d) propose resolution preserving both intents, (e) if intents conflict, present options to the user.
Stacked-PR detection — compare base/HEAD/incoming similarity; on high overlap, likely a stacked-PR rebase → prefer incoming (later branch) and warn about cascade to downstream branches.
Validate — git diff to review; run stack-specific checks (build/lint/test); present a summary before continuing.
Continue — git add <resolved-files>, then git rebase --continue (or merge/revert/cherry-pick --continue). If new conflicts appear (common in multi-commit rebases), loop back to step 1 until the operation completes.
Examples
User: "merge conflict in src/auth.ts, both branches changed the token validator"
/ai-resolve-conflicts
Reads both sides, categorizes as code, applies intent-aware resolution (preserves both validators if non-overlapping; otherwise asks the user with a unified diff), stages, continues the operation.
Integration
Called by: /ai-pr watch-and-fix loop (CI repair), user directly. Calls: git (rebase / merge / cherry-pick continuation), package managers (lock-file regeneration). See also: /ai-branch-cleanup (after resolution), /ai-commit (commit the resolved state).
$ARGUMENTS
1---2name: ai-resolve-conflicts3description: Resolves git conflicts intent-aware: categorizes by type (lock files, migrations, generated, config, code), regenerates or merges per category, never blindly accepts. Trigger for 'I have conflicts', 'rebase failed', 'merge conflict', 'cherry-pick failed', 'unmerged paths'. Not for branch hygiene; use /ai-branch-cleanup instead. Not for committing the resolution; use /ai-commit instead.4---567# Resolve Conflicts89Intent-aware git conflict resolution: detect the operation, categorize files by strategy (lock, migration, generated, config, code), and resolve with awareness of both sides — never blindly accept. Use it whenever `git status` shows unmerged paths after a rebase, merge, cherry-pick, or revert.1011```12/ai-resolve-conflicts # auto-detect and resolve current conflicts13```1415## Workflow1617Principles: §10.1 KISS (category-routing over a single generic merge); §10.4 DRY (regenerate lock/generated files rather than hand-merge).18191. **Detect operation** in progress:2021 ```bash22 test -d .git/rebase-merge || test -d .git/rebase-apply # rebase23 test -f .git/MERGE_HEAD # merge24 test -f .git/CHERRY_PICK_HEAD # cherry-pick25 test -f .git/REVERT_HEAD # revert26 ```27282. **List conflicts** — `git diff --name-only --diff-filter=U`.293. **Categorize** each file:3031 | Category | File patterns | Strategy |32 |----------|--------------|----------|33 | Lock files | `*.lock`, `poetry.lock`, `Cargo.lock`, `package-lock.json`, `uv.lock` | Accept theirs, regenerate |34 | Migrations | `migrations/`, `alembic/versions/` | Ask user (order matters) |35 | Generated | `*.min.js`, `*.min.css`, `dist/`, `build/` | Accept theirs, rebuild |36 | Config | `*.yml`, `*.toml`, `*.json` (non-lock) | AI merge with validation |37 | Code | everything else | AI analysis |38394. **Resolve by category**:40 - **Lock files** — `git checkout --theirs <lockfile>`, then regenerate (`npm install` / `cargo generate-lockfile` / `uv lock`).41 - **Migrations** — present both sides + migration graph; ask which order (never auto-resolve — ordering is semantic).42 - **Config** — merge preserving both sides' additions; validate against schema if available.43 - **Code** — per hunk: (a) read 50 lines context each side, (b) identify intent per side, (c) check commit messages, (d) propose resolution preserving both intents, (e) if intents conflict, present options to the user.445. **Stacked-PR detection** — compare base/HEAD/incoming similarity; on high overlap, likely a stacked-PR rebase → prefer incoming (later branch) and warn about cascade to downstream branches.456. **Validate** — `git diff` to review; run stack-specific checks (build/lint/test); present a summary before continuing.467. **Continue** — `git add <resolved-files>`, then `git rebase --continue` (or `merge`/`revert`/`cherry-pick --continue`). If new conflicts appear (common in multi-commit rebases), loop back to step 1 until the operation completes.4748## Examples4950User: "merge conflict in src/auth.ts, both branches changed the token validator"5152```53/ai-resolve-conflicts54```5556Reads both sides, categorizes as code, applies intent-aware resolution (preserves both validators if non-overlapping; otherwise asks the user with a unified diff), stages, continues the operation.5758## Integration5960Called by: `/ai-pr` watch-and-fix loop (CI repair), user directly. Calls: git (rebase / merge / cherry-pick continuation), package managers (lock-file regeneration). See also: `/ai-branch-cleanup` (after resolution), `/ai-commit` (commit the resolved state).6162$ARGUMENTS