resolve-conflict
Walk a developer through a git merge or rebase conflict carefully — read each conflicted file's `<<<<<<<` markers, understand both sides' intent before choosing, present per-file resolutions, and never silently discard one side's work. Handles lockfile conflicts (regenerate, don't hand-merge), generated-file conflicts (rebuild, don't merge), and semantic conflicts where both sides edit different lines but the combined result is broken. Trigger phrases — "resolve conflicts", "I have merge conflicts", "fix this rebase", "/resolve-conflict", "stuck in a rebase", "merge conflict help". Skip for — clean merges, conflicts the user has already resolved, force-push or "just take theirs/ours" requests where the user has explicitly accepted the loss of one side.
- License 许可
- MIT
- 最近更新
- 2026-07-07
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- resolve-conflict
- license
- MIT
- metadata
- { "source": "Adapted from AgentSystemLabs/core (MIT)", "requires_codegraph": true }
- description
- Walk a developer through a git merge or rebase conflict carefully — read each conflicted file's `<<<<<<<` markers, understand both sides' intent before choosing, present per-file resolutions, and never silently discard one side's work. Handles lockfile conflicts (regenerate, don't hand-merge), generated-file conflicts (rebuild, don't merge), and semantic conflicts where both sides edit different lines but the combined result is broken. Trigger phrases — "resolve conflicts", "I have merge conflicts", "fix this rebase", "/resolve-conflict", "stuck in a rebase", "merge conflict help". Skip for — clean merges, conflicts the user has already resolved, force-push or "just take theirs/ours" requests where the user has explicitly accepted the loss of one side.
- compatibility
- opencode
03 SKILL.md 正文
Tool mapping (OpenCode): This skill uses:
questiontool for user prompts (notAskUserQuestion)tasktool for subagents (notAgentorTasksubagent syntax)skill({ name: "..." })to load other skills (notSkill(skill="...", args="..."))codegraph_explore,codegraph_search,codegraph_contextfor codebase exploration (preferred)todowritefor phase/progress trackinggrep,glob,read,bashas fallback when.codegraph/not initializedContext rule: This skill supersedes any prior skill instructions. Follow ONLY these instructions now. Read the user's goal and any mode/include/skip from the conversation context.
Read mode=, include=, and skip= from the conversation context. Default to the mode specified in this skill if not provided.
Resolve Conflict
A merge conflict means git could not pick — both branches changed the same lines. The dangerous failure mode is "pick theirs" or "pick ours" without reading both, which silently throws away work. This skill exists to make that failure mode hard.
Phase 1 — Identify the State
Use todowrite to mark this phase as in_progress. Mark it completed when done.
Determine what operation is mid-flight:
.git/MERGE_HEADexists → in a merge..git/REBASE_HEADor.git/rebase-merge/or.git/rebase-apply/→ in a rebase..git/CHERRY_PICK_HEAD→ in a cherry-pick.- None of the above +
git statusshows conflicts → likely a stash pop or apply.
Run git status to list Unmerged paths. Group them:
| Group | Paths | Strategy |
|---|---|---|
| Lockfiles | package-lock.json, pnpm-lock.yaml, yarn.lock, bun.lockb, Cargo.lock, poetry.lock, uv.lock, Gemfile.lock, go.sum |
Regenerate, do not hand-merge. |
| Generated | *.gen.ts, files in drizzle/, __generated__/, dist/ |
Rebuild from source after resolving the source files. |
| Source | everything else | Hand-resolve per Phase 3. |
Exit: the operation is identified and the file groups are listed.
Phase 2 — Resolve Lockfiles First
Use todowrite to mark this phase as in_progress. Mark it completed when done.
For each lockfile in the lockfile group:
# 1. Take the version that matches the package manifest's resolved tree:
git checkout --theirs <lockfile> # or --ours, depending on which side's package.json wins
# 2. Regenerate to make sure it actually matches:
<install command without writing manifest changes> # e.g. pnpm install --no-frozen-lockfile
# 3. Stage:
git add <lockfile>
If the conflict is in package.json (or pyproject.toml etc.) too, resolve that first as a source file, then regenerate the lockfile from the merged manifest.
Exit: all lockfiles staged with a regenerated, internally-consistent state.
Phase 3 — Resolve Source Files
Use todowrite to mark this phase as in_progress. Mark it completed when done.
For each source file in the source group:
-
Read the whole file — not just the conflict markers. Context above and below tells you what the function/component is supposed to do.
-
Identify each conflict block (
<<<<<<<…=======…>>>>>>>). For each block, write down in your head:- What was on the HEAD/ours side trying to do?
- What was on the incoming/theirs side trying to do?
- Are they: identical intent (just whitespace/format), complementary (both should land), or incompatible (one must win)?
-
Resolve per block:
Case Resolution Identical intent Keep one side; check formatting matches project style. Complementary (e.g., both added a different prop, both added a different import) Combine both changes. Incompatible (both edit the same logic differently) Stop. Surface to the user via questiontool with both versions side-by-side. Do not guess.One side is clearly a refactor that subsumes the other Keep the refactor side and re-apply the other side's intent on top. -
Remove all markers (
<<<<<<<,=======,>>>>>>>). If any remain, the file is not resolved. -
Run typecheck/lint on the file if the project supports it. Resolution that compiles is necessary but not sufficient.
-
git add <file>.
Exit: every source file is staged, and every "incompatible" case has been surfaced to the user with their explicit choice recorded.
Phase 4 — Rebuild Generated Files
Use todowrite to mark this phase as in_progress. Mark it completed when done.
After source files are resolved, regenerate any generated files that conflicted:
- Drizzle migrations: re-run the codegen command.
- GraphQL/OpenAPI codegen: re-run the codegen.
- Build artifacts: rebuild.
Do not hand-merge generated files. The output of regeneration is the source of truth.
git add the regenerated files.
Exit: generated files match what regeneration produces from the merged source.
Phase 5 — Continue the Operation
Use todowrite to mark this phase as in_progress. Mark it completed when done.
- Merge:
git commit(the message is pre-populated). - Rebase:
git rebase --continue. - Cherry-pick:
git cherry-pick --continue.
If the next commit in a rebase produces another set of conflicts, loop back to Phase 1 with the new state. Each commit's conflicts are resolved independently — do not try to "resolve all rebase conflicts at once".
If the user wants to abort: git merge --abort / git rebase --abort / git cherry-pick --abort. Recommend this if the conflict count is high (>10 files) and the user wasn't expecting the operation — abort, regroup, then retry with a different strategy.
Phase 6 — Report
Use todowrite to mark this phase as in_progress. Mark it completed when done.
Resolved <N> conflicted files.
Lockfiles: <count> regenerated
Generated: <count> rebuilt
Source: <count> hand-merged
Combined both sides: <list>
Took ours: <list> (with reason)
Took theirs: <list> (with reason)
Refactor + re-apply: <list>
Verify before pushing: <test command>
Remind the user to run the test suite — a successful merge can still be semantically broken.
NEVER
-
NEVER use
git checkout --theirsor--ourson a source file without reading both versions first. Instead: read the file, identify each block's intent, choose per block. Use--theirs/--oursonly on lockfiles and generated files. Why:--theirson a whole source file silently discards every change ours made to that file — hours of work, gone with no diff to review. The fastest-feeling resolution is the most destructive. -
NEVER hand-merge a lockfile. Instead: take one side, regenerate from the manifest. If the manifests conflict, resolve manifests first. Why: lockfiles encode a graph of resolved versions and integrity hashes. A hand-merged lockfile produces a tree that no install ever computed — installs will diverge between machines and CI.
-
NEVER guess on incompatible blocks. Instead: stop, present both versions, use
questiontool to ask the user which intent should win. Why: the conflict marker exists exactly because git couldn't decide. If you "decide" without checking, you're committing a bug — possibly the bug each side was trying to fix differently. Only the human knows which is right. -
NEVER consider a file resolved while a conflict marker remains. Instead: grep for
<<<<<<<,=======,>>>>>>>after each file. Any hit means the file is not done. Why: stray markers compile in some languages (no, they don't), break builds, and ship to production if missed. The check costs nothing. -
NEVER continue the rebase/merge while there are unresolved files in
git status. Instead: finish every Unmerged path first; verify withgit statusthat the list is clean. Why:git rebase --continuewith unmerged paths errors out — butgit commiton a merge with some files staged and some still conflicted will silently commit a half-resolved tree if the conflict markers happen to be in unstaged hunks. Defense in depth: always verify status is clean. -
NEVER bundle "while I'm here" cleanup into a conflict resolution. Instead: restrict edits to the conflict blocks. Refactors go in a follow-up commit. Why: a conflict resolution diff that includes unrelated changes is impossible to review. Reviewers cannot tell which lines came from which side; bisect later cannot tell the resolution from the refactor.
-
NEVER treat a successful build as proof of a correct resolution. Instead: run the test suite; a passing build only means the code compiles. Why: the most common merge bug is two complementary changes that compile together but produce wrong behavior — both branches edited a state machine in compatible-looking ways that combined into a logical error. Tests are the only thing that catches this.
04 同仓库更多 Skills
write-tests
暂无简介
update-changelog
暂无简介
triage
Move issues and external PRs through a state machine of triage roles — categorise, verify, grill if needed, and write agent-ready briefs.
to-prd
暂无简介
to-issues
Break a plan, spec, or PRD into independently-grabbable issues on the project issue tracker using tracer-bullet vertical slices.
testing-plan
暂无简介