Resolve Merge Conflicts
- Guard: run
git rev-parse -q --verify MERGE_HEAD || git rev-parse -q --verify REBASE_HEAD; if neither resolves (no merge/rebase in progress), stop with "No merge in progress." - Plan read-only — make no writes until the gate (step 5). Run
git status --shortand classify each conflicted file AUTO or JUDGMENT. - AUTO = resolution provably safe by a mechanical check; default everything else to JUDGMENT. AUTO cases:
- Sides byte-identical (
git show :2:<f>vs:3:<f>) or differing only in whitespace/EOL → take either. - AU →
git add, butgit rmif its slug already exists in theirs at another number (duplicate). - Lock file → checkout one side, regenerate via the package manager.
CHANGELOG.md→ merge unique entries, dedupe, keep category order.
- Sides byte-identical (
- Numbered docs (
docs/plans/NNNN__*,docs/chronicles/NNNN__*): use THEIRS numbering as base, place each OURS-unique file at the next free number on collision, leave no gaps or duplicates; then fix internal refs so each plan's research ref and each chronicle's self-ref match its own number and every cross-ref resolves. - Present the full plan (every conflicted file, untruncated: file · code · action · AUTO/JUDGMENT) and gate once via
AskUserQuestion: Approve / Modify / Abort. Abort leaves all files untouched. - Execute approved AUTO actions silently; report only counts and errors.
- For each JUDGMENT file, show only the OURS hunk, the THEIRS hunk, and your proposed merge (those exact bytes, no outer fence, invent nothing); ask Approve / Edit / Skip. Skip leaves the conflict.
- Any single failure (e.g. lock-file regen) → leave that file conflicted, continue, list it under
Skipped. Never abort the run for one file. - Verify: no conflict markers in tracked files, numbering and refs intact if docs changed, plus any known build/lint check.
- Report a compact summary (
N resolved: X AUTO, Y JUDGMENT; Skipped: …), then hand off to/commit— do not commit. If a check fails, report the failure and stop.
(Codex: replace each AskUserQuestion gate with a numbered list + STOP — see ../using-development-skills/references/codex-tools.md.)