claude/skills/merge-resolve/SKILL.md
Resolve merge conflicts, rebase conflicts, and cherry-pick failures using mergiraf (AST-aware structural merge), git rerere, and kdiff3. Activate when: merge failed, rebase conflict, cherry-pick failed, CONFLICT in file, "resolve conflicts", "fix merge", "merge conflict", "conflict resolution", or git output shows CONFLICT markers. Also use for mergiraf diagnostics, rerere management, gitattributes regeneration, or batch conflict resolution across multiple files. Covers the full resolution chain: mergiraf (structural auto-resolve) → rerere (replay remembered fixes) → kdiff3 (manual). Do NOT use for general git operations without conflicts — those go to the commit or gh skills.
npx skillsauth add paulnsorensen/dotfiles merge-resolveInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Resolve merge conflicts using the structural merge chain: mergiraf → rerere → kdiff3.
The three tools form a cascade — each handles what the previous couldn't:
mergiraf runs automatically as a git merge driver. It parses all three file versions (base, ours, theirs) into Tree-sitter ASTs and merges structurally. Independent additions (imports, functions, struct fields) merge cleanly even when text-based merge would conflict. Falls back to text merge if parsing fails — never makes things worse.
rerere ("reuse recorded resolution") activates after mergiraf. If you manually resolved the same conflict before, rerere replays that resolution automatically. Especially valuable during long rebases where the same conflict recurs across commits.
kdiff3 is the manual fallback for conflicts neither tool could resolve. Launch with
git mergetool — it opens a 3-way diff view for human decision-making.
Note: <skill-dir> refers to the directory containing this SKILL.md file.
Run the summary script first — it replaces the need for grep -n '<<<<<<<' and ad-hoc parsers:
python3 <skill-dir>/scripts/conflict-summary.py
This outputs for each conflicted file:
For JSON output (scripting): --json. For more context: --context 10.
If you need raw git info too:
git log --merge --oneline # What commits are involved?
For files where mergiraf is configured but conflicts remain (meaning the structural merge already ran and couldn't fully resolve), you can inspect what mergiraf produced vs text merge:
# Extract the 3-way inputs from git's stage slots
git show :1:<path> > /tmp/base # Stage 1 = common ancestor
git show :2:<path> > /tmp/ours # Stage 2 = current branch (HEAD)
git show :3:<path> > /tmp/theirs # Stage 3 = incoming branch
# Preview what mergiraf would produce (writes to -o, doesn't touch working copy)
mergiraf merge /tmp/base /tmp/ours /tmp/theirs -o /tmp/merged -p <path>
# Check if clean (no conflict markers)
grep -c '<<<<<<' /tmp/merged # 0 = clean
If the merged output has no conflict markers, mergiraf resolved it cleanly — the git merge driver may have fallen back to text merge due to a parse error or size limit. Apply the clean output:
cp /tmp/merged <path>
git add <path>
For repos with many conflicted files, use the batch script:
# Preview what can be resolved (no file changes)
python3 <skill-dir>/scripts/batch-resolve.py --dry-run
# Apply all clean resolutions
python3 <skill-dir>/scripts/batch-resolve.py --apply
# With mergiraf debug output
python3 <skill-dir>/scripts/batch-resolve.py --dry-run --verbose
The script extracts 3-way inputs for every conflicted file, runs mergiraf merge
on them, and reports which files resolved cleanly vs which need manual intervention.
After structural resolution, for files that still have conflict markers:
Check rerere first:
git rerere status # Files with recorded resolutions
git rerere diff # Show what rerere would apply
If rerere has a resolution, it was already applied. If not, guide the user to manual resolution:
git mergetool # Opens kdiff3 for each conflicted file
# Or for a specific file:
git mergetool <path>
After manual resolution:
git add <resolved-files>
# Then continue the interrupted operation:
git merge --continue # or
git rebase --continue # or
git cherry-pick --continue
When mergiraf isn't resolving something you expect it to:
# Run with debug logging to see parse results and matching decisions
RUST_LOG=mergiraf=debug mergiraf merge /tmp/base /tmp/ours /tmp/theirs -o /tmp/merged -p <path> 2>&1
# Check if the file type is registered
mergiraf languages | grep <extension>
# Verify gitattributes
git check-attr merge -- <path>
# Should show: <path>: merge: mergiraf
Common issues:
~/.gitattributes — regenerate after upgrade--size-limitRegenerate gitattributes after mergiraf upgrade:
mergiraf languages --gitattributes > ~/.gitattributes
Manage rerere state:
git rerere status # What's currently being tracked
git rerere diff # Pending resolution diffs
git rerere forget <path> # Forget a bad resolution for one file
git rerere gc # Clean old entries (default: 60 days unresolved, 15 days resolved)
ls .git/rr-cache/ # Browse the resolution database
Four scripts and a shared utility module in <skill-dir>/scripts/ cover the common patterns:
| Script | Purpose | When to use |
|--------|---------|-------------|
| conflict-summary.py | Structured summary with line numbers + context | Always run first — replaces grep for <<<<<<< |
| batch-resolve.py | Run mergiraf merge on all conflicted files | Supported langs with structural conflicts |
| conflict-pick.py | Choose ours/theirs per hunk | Shell, SQL, .gitignore, or formats not handled by mergiraf (e.g. Markdown without a .gitattributes entry) |
| lockfile-resolve.py | Take one side + regenerate lockfile | Cargo.lock, package-lock.json, yarn.lock, etc. |
| git_utils.py | Shared utilities — conflict detection, mergiraf support check | Internal — imported by other scripts |
conflict-pick.py — for file types not handled by mergiraf in this repo (shell scripts, .gitignore, or Markdown when .md isn't registered in .gitattributes):
# Take ours for all hunks
python3 <skill-dir>/scripts/conflict-pick.py hooks/session-start.sh --ours
# Take theirs for all hunks
python3 <skill-dir>/scripts/conflict-pick.py .gitignore --theirs
# Prompt per hunk (interactive)
python3 <skill-dir>/scripts/conflict-pick.py hooks/runner.sh --interactive
# Take ours only for hunks matching a pattern (leave others as conflicts)
python3 <skill-dir>/scripts/conflict-pick.py config.yaml --grep "timeout" --ours
lockfile-resolve.py — the cargo.lock pattern from real sessions: take theirs, regenerate:
# Auto-detect conflicted lockfiles and regenerate (default: theirs + regen)
python3 <skill-dir>/scripts/lockfile-resolve.py
# Just regenerate if manifest is already resolved
python3 <skill-dir>/scripts/lockfile-resolve.py --strategy regen
# Preview
python3 <skill-dir>/scripts/lockfile-resolve.py --dry-run
Supports: Cargo.lock, package-lock.json, yarn.lock, pnpm-lock.yaml,
poetry.lock, Pipfile.lock, uv.lock, Gemfile.lock, go.sum.
Lockfiles need special handling — textual or structural merge produces valid syntax
but potentially invalid dependency graphs. Use lockfile-resolve.py (see Scripts above).
The proven pattern (from session history): take --theirs on the lockfile, then
regenerate from the merged manifest. Works for Cargo.lock, package-lock.json, yarn.lock,
poetry.lock, uv.lock, go.sum, and more.
If one branch ran a formatter (rustfmt, prettier) while the other modified content, mergiraf may produce more conflicts than text merge because AST positions shifted. Resolution: run the formatter on the merged result after resolving conflicts.
If the conflict state is unrecoverable:
git merge --abort # or
git rebase --abort # or
git cherry-pick --abort
For the full mergiraf CLI reference, supported languages, troubleshooting guide,
and performance tips, read <skill-dir>/references/mergiraf-guide.md.
mergiraf solve flag confusion: use --stdout/-p for preview, NOT --output (that's for mergiraf merge)||||||| sections — all scripts handle it but custom parsers must account for itThe skill agent aggregates results across all scripts and reports a unified summary:
If remaining > 0: list files + next action. If 0: "All resolved. Continue with git merge/rebase/cherry-pick --continue"
tools
Reconstruct what a past coding-agent session was doing so you can resume it — goal, files touched, last verified state, and the next step — by querying the session logs. Use when the user says "what was I working on", "recover that session", "reconstruct where I left off", "resume my last session", "what did that session change", "rebuild context from logs", or invokes /work-recovery. Report-only — it never scores or judges. Do NOT use for usage scoring (that is /skill-improver, /tool-efficiency, /prompt-analytics) or one-off interactive log queries (that is /session-analytics).
development
Curate this repo's hallouminate wiki (.hallouminate/wiki/, the repo:dotfiles:wiki corpus) — add or update architecture pages, per-harness docs, and gotchas. Use when the user says "update the wiki", "document this in the wiki", "refresh the harness docs", "add a wiki page", "curate the wiki", "the wiki is stale", or invokes /wiki-curator. Also use at session end to write back a non-obvious decision or gotcha worth preserving. Grounds the existing wiki first, follows one-topic-per-file conventions, verifies every external doc URL before writing, and reindexes. Do NOT use for general code search (that is cheez-search) or for editing AGENTS.md command reference.
tools
Audit how a tool, command, or MCP server is actually used across coding-agent sessions and produce calibrated recommendations — tool-vs-task fit, error forensics, fix recommendations, permission friction, MCP health, and token economics. Use when the user says "tool efficiency", "am I using X efficiently", "audit tool usage", "why does X keep failing", "how do I fix this error", "what should I change", "permission friction", "is this MCP worth it", "tool error rate", "fix recommendations", or invokes /tool-efficiency. Do NOT use for auditing a skill or agent definition (that is /skill-improver) or for one-off interactive log queries (that is /session-analytics).
tools
Analyze how prompts and skill routing behave across coding-agent sessions and produce calibrated recommendations — prompt-pattern analysis, routing accuracy, and knowledge gaps. Use when the user says "analyze my prompts", "prompt patterns", "is routing working", "which skill should have fired", "knowledge gaps", "what do I keep asking", or invokes /prompt-analytics. Do NOT use for auditing a single skill/agent definition (that is /skill-improver), tool/MCP efficiency (that is /tool-efficiency), or one-off interactive log queries (that is /session-analytics).