一键导入
conflict-resolver
Resolve git merge/rebase conflicts by analyzing git history, commit intent, and code context. Use when merge or rebase produces conflicts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Resolve git merge/rebase conflicts by analyzing git history, commit intent, and code context. Use when merge or rebase produces conflicts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create or update AGENTS.md / CLAUDE.md using industry best practices. Use when the user asks to create AGENTS.md, update project documentation, or after code changes that need documentation updates.
Save successful workflows as reusable pi skills. Use when a workflow worked well and should be preserved for future use.
4-phase root cause debugging: understand bugs before fixing.
TDD: enforce RED-GREEN-REFACTOR, tests before code.
| name | conflict-resolver |
| description | Resolve git merge/rebase conflicts by analyzing git history, commit intent, and code context. Use when merge or rebase produces conflicts. |
Resolve merge and rebase conflicts by understanding WHY both sides made their changes, then choosing the right resolution based on intent — not just line-by-line diffing.
git merge / git rebase / git cherry-pick produced conflictsgit rebase origin/mainBefore touching any file, gather context:
# List all conflicted files
git diff --name-only --diff-filter=U
# Show ALL conflict types (UU=both modified, AA=both added, etc.)
git status --porcelain | grep "^[UAD][UAD]"
# What caused the conflict? (worktree-safe — no .git/ path assumptions)
if git rev-parse --verify -q MERGE_HEAD >/dev/null 2>&1; then
echo "MERGE — ours=HEAD, theirs=MERGE_HEAD"
THEIRS="MERGE_HEAD"
elif git rev-parse --verify -q REBASE_HEAD >/dev/null 2>&1; then
echo "REBASE — ours=upstream (HEAD), theirs=your commits (REBASE_HEAD) — swapped!"
THEIRS="REBASE_HEAD"
elif git rev-parse --verify -q CHERRY_PICK_HEAD >/dev/null 2>&1; then
echo "CHERRY-PICK — ours=HEAD, theirs=CHERRY_PICK_HEAD"
THEIRS="CHERRY_PICK_HEAD"
fi
# For EACH conflicted file — see what each side changed
git log --oneline $THEIRS..HEAD -- <file> # our commits
git log --oneline HEAD..$THEIRS -- <file> # their commits
# Get blame for context
git blame HEAD -- <file> | head -30
git blame $THEIRS -- <file> | head -30
# View the actual conflict markers
grep -n "<<<<<<\|======\|>>>>>>" <file>
⚠️ During rebase, --ours and --theirs are SWAPPED:
git merge: --ours = your branch, --theirs = incominggit rebase: --ours = upstream (the branch you're rebasing onto), --theirs = your commitsIron Law: understand BOTH sides before resolving. Never blindly accept one side.
Classify each side's changes by intent:
| Type | Indicators | Resolution Priority |
|---|---|---|
| Security fix | "security", "vuln", "CVE" in commit message | Highest — always keep |
| Bug fix | "fix", "bug", "patch" in commit message; small targeted change | Highest — always keep |
| Refactor | "refactor", "cleanup", "rename"; no behavior change | Medium — preserve both if compatible |
| Feature | "feat", "add", "implement"; new functionality | Medium — merge carefully |
| Style | "style", "format", "lint"; whitespace/formatting only | Lowest — accept either side |
package-lock.json, uv.lock, yarn.lock, pnpm-lock.yaml) → NEVER merge manually.
Resolve the manifest first (package.json, pyproject.toml, etc.), then regenerate:# Step 1: Resolve the manifest file (package.json, pyproject.toml) normally
# Step 2: Delete the conflicted lock file and regenerate
# For uv.lock
rm -f uv.lock
uv lock
# For package-lock.json
rm -f package-lock.json
npm install
# For yarn.lock
rm -f yarn.lock
yarn install
The manifest defines WHAT you want. The lock file is generated FROM the manifest. Never pick a side for the lock file — just regenerate it.
# Accept theirs entirely (incoming changes)
git checkout --theirs <file>
git add <file>
# Accept ours entirely (current branch changes)
git checkout --ours <file>
git add <file>
⚠️ During rebase, --ours/--theirs are swapped. If unsure, use git diff :2:<file> :3:<file> to compare stage 2 (ours) vs stage 3 (theirs) directly.
# Manual resolution
# 1. Open file, read conflict markers
# 2. Remove <<<<<<< ======= >>>>>>> markers
# 3. Combine changes based on intent analysis
# 4. Verify syntax
git add <file>
# No remaining conflict markers
grep -rn "<<<<<<\|======\|>>>>>>" <resolved-files>
# No unresolved files
git diff --name-only --diff-filter=U
# Syntax check (language-dependent)
# Python
uv run python -c "import ast; ast.parse(open('<file>').read())"
# TypeScript/JavaScript
npx tsc --noEmit
# Go
go build ./...
# Run tests
uv run pytest -q # or npm test, go test, etc.
# For merge
git add <all-resolved-files>
git commit # uses merge commit message
# For rebase
git add <all-resolved-files>
git rebase --continue
Both sides added different imports → keep all, deduplicate:
# OURS
from module import foo, bar
# THEIRS
from module import foo, baz
# RESOLVED
from module import bar, baz, foo
Both sides changed the same function → merge logic:
Both sides added different config entries → merge sections:
# Usually safe to keep both additions
# Watch for duplicate keys — last one wins in YAML
| Don't | Why | Instead |
|---|---|---|
git checkout --ours . | Discards ALL incoming changes | Resolve file by file |
| Manually edit lock files | Corrupts dependency resolution | Regenerate from scratch |
| Skip git blame | Wrong intent, wrong resolution | Always check commit history |
| Resolve without understanding | Creates subtle bugs | Read both sides first |
| Accept AI's first suggestion blindly | AI often picks one side | Verify the merge makes sense |