pull-changes-resolve-conflicts
cognitedata/builder-skills
在多贡献者项目(包括 Flows 应用)中,从主分支或其他分支获取更新的标准工作流程,可避免在未经通知的情况下丢弃现有工作。该流程指导用户如何执行获取与合并操作,要求明确列出合并冲突,通过对话记录和仓库上下文分析双方代码的差异,提供按优先级排序的建议,并在修改冲突标记或完成合并之前获取用户确认。触发场景包括:拉取主分支、合并主分支、合并 origin 分支、执行 rebase 操作、出现合并冲突以及存在未合并的暂存区。
...展开全部关于 pull-changes-resolve-conflicts
这是一套专为多贡献者项目设计的引导式工作流程,用于将一个分支集成到另一个分支中(通常是把 main 分支拉取或合并到特性分支中),同时避免无意中丢弃他人已完成的代码工作。该流程适用于任何基于 Git 的团队协作模式,尤其常见于 Flows/React 应用——这类应用中的冲突往往集中在应用外壳、顶部导航、路由模块以及共享的 lib/ 或 hooks/ 目录中。其核心原则是,在进行分析之前绝不能擅自认定“main 分支的代码必胜”或“我方代码必胜”,且在修改任何冲突标记之前,必须让使用者清楚了解所涉及的权衡因素。
工作流程分阶段进行:首先执行获取并集成操作(除非用户要求使用 rebase,否则优先采用 git fetch 后再执行 git merge origin/main);接着明确列出所有未合并的文件,并简要说明导致差异的原因;随后通过对话历史记录、仓库中的相关文档(如 PRD.md 或近期提交记录),以及通过 git show :2:path 查看我方代码内容、git show :3:path 查看对方代码内容来分析冲突。冲突会被分为三类:正交冲突(可安全合并)、重叠冲突(需手动选择或合并),以及数据损坏风险冲突(由错误合并导致的重复代码块)。分析结果会以优先级排序的形式呈现为建议和明确的问题,优先级从 P0(结构性/产品层面的变更,如路由被删除、功能被移除、数据或 API 接口协议发生变化)到 P3(界面层面的微调,如间距、类名调整)不等。
该工具严格执行“不得自动隐藏冲突”的硬性规则:在用户同意处理方案或明确接受建议之前,不会删除冲突标记,也不会执行 git add 操作。它会在遇到冲突时暂停处理,而非强行继续处理大文件,并支持通过 git merge --abort 或 git rebase --abort 来中止当前操作。此外,它还列出了应避免的错误做法,比如在整个仓库中统一选择 --ours 或 --theirs,或在没有简短总结的情况下将冲突列表隐藏在冗长的代码片段中。相关的可选命令示例和合并消息模板均放在附带的 reference.md 文件中。
常见问题
什么时候应该使用此工具?
每当您需要将另一个分支(通常是 main 分支)集成到当前的特性分支中,或者在执行合并或 rebase 后发现 git status 显示有未合并的路径时,都可以使用它。该工具适用于任何基于 Git 的团队协作模式,Flows/React 应用是典型的应用场景。
它会自动解决冲突而不需要我操作吗?
不会。有严格的硬性规则禁止自动隐藏冲突:在您同意处理方案或明确要求按照其建议操作之前,它不会删除冲突标记,也不会执行 git add 操作。它会先在遇到冲突时暂停,并将冲突情况告知您。
它是如何决定先处理哪些冲突的?
冲突会按照影响程度排序,从 P0 级别(结构性/产品层面的变更,如路由被删除、功能被移除、数据或 API 接口协议发生变化)到 P3 级别(界面层面的微调,如间距、类名和文案调整)依次处理。
在编辑之前,它依靠哪些信息来分析冲突?
它会参考关于该分支所包含功能的对话历史记录、仓库中的相关文档(如 PRD.md 或近期提交记录)以及文件归属信息,同时通过 git show :2:path 查看我方代码内容,再通过 git show :3:path 查看对方代码内容,以此来分析冲突。
如果我只是想中止合并操作怎么办?
该工具支持根据情况执行 git merge --abort 或 git rebase --abort 操作,并会提示您该操作会导致正在进行的集成状态丢失。
所有文件
2 个文件 reference.md 0.7 KB 查看 SKILL.md 5.5 KB 查看
Use this skill whenever integrating another branch (usually main) into the current feature branch, or when git status shows unmerged paths after a merge or rebase. Applies to any Git-based team workflow; Flows/React apps are a common case where conflicts cluster in app shells and shared libraries.
Goals
- Preserve intentional work on the current branch; do not assume “main wins” or “ours wins” without analysis.
- Make trade-offs visible to the user before any conflict resolution edits.
- Order discussion by impact: structural / feature / API / data-model changes before styling, copy, or spacing.
Hard rules
- No silent resolution — Do not remove
<<<<<<</=======/>>>>>>>or rungit addon conflicted files until the user has agreed to the plan (or explicitly says “use your recommendations”). - Stop at conflicts — If a merge or rebase introduces conflicts, pause and report; do not bulldoze through large files by picking one side wholesale unless the user explicitly requests that.
- Prioritize impact — When presenting conflicts, group and order roughly as:
- P0 — Structural / product: removed routes, deleted modules, dropped features, changed data or API contracts, SDK or schema changes, auth or routing shell.
- P1 — Behavior: logic, hooks, queries, filters, error handling, loading states.
- P2 — UI structure: layout regions, new or removed sections, navigation.
- P3 — Presentation: tokens, spacing, class names, copy tweaks.
Workflow
1. Fetch and integrate (or diagnose)
- Prefer
git fetchthengit merge origin/main(or the named branch) unless the user asked for rebase. - If merge is already in progress, run
git statusand list every unmerged file.
2. Report conflicts to the user (explicit)
Output a clear list:
- Branch state: current branch, target branch (e.g.
origin/main), merge vs rebase. - Unmerged files: paths only, then optionally
git diff --name-only --diff-filter=U. - Per file (short): one line on what diverged (e.g. “
AlertsPage— layout + new data scope”) if inferable from paths andgit diffwithout resolving.
3. Analyze before editing
Use all of:
- Conversation history — What was the user or team trying to ship on this branch?
- Repo signals — Product or architecture docs if present (e.g.
PRD.md), recent commits on the current branch, file ownership (e.g. large feature module vs sharedlib/). - Conflict hunks —
git show :2:path(ours) vsgit show :3:path(theirs) during merge, or read conflict markers; identify duplicated vs orthogonal changes.
Classify each conflicted area as:
- Orthogonal — safe to combine (e.g. import sort + new prop).
- Overlapping — must choose or manually merge (same lines).
- Corruption risk — duplicated blocks (common after bad merges); flag and recommend reconstructing from one side then re-applying the other side’s intent manually.
4. Recommendations + questions (required)
Present to the user:
- Summary table or bullets — file → recommended side or “manual merge” → one-line why.
- Ordered by P0 → P3 — call out anything that removes a feature or changes public behavior first.
- Explicit questions — anything ambiguous (e.g. “Keep main’s global behavior or the branch’s scoped variant?”).
- Ask for direction — e.g. “Reply with: (a) follow recommendations, (b) keep branch for file X, (c) keep main for file Y, (d) abort merge.”
Only after the user confirms (or gives a precise mapping), apply resolutions:
- Prefer small, surgical edits; preserve both sides’ intent when possible.
- Re-run
git status; ensure no conflict markers remain; run tests or lint the user cares about for touched areas.
5. If the user wants to abort
git merge --abortorgit rebase --abortas appropriate; confirm they lose in-progress integration state for that operation.
Anti-patterns (do not do)
- Picking
--ours/--theirson the whole repo without user approval. - “Resolving” by deleting a feature branch’s work because main touched the same file.
- Hiding conflict lists inside a long code dump without a short executive summary.
- Fixing low-impact style conflicts first while leaving P0 decisions implicit.
Quick reference
- Ours vs theirs (merge): stage 2 = current branch (
HEAD), stage 3 = incoming (MERGE_HEAD). Verify withgit checkout --conflict=merge <file>if needed. - Typical high-touch paths in full-stack or Flows apps: root app shell, top navigation, route modules, and shared
lib/orhooks/.
For optional command snippets and a merge message template, see reference.md.
所有文件
0 个文件安装 pull-changes-resolve-conflicts
将技能文件下载并解压到您的 .claude/skills/ 目录中。
下载ZIP克隆仓库并复制技能文件到您的项目中。
git clone https://github.com/cognitedata/builder-skills/blob/main/skills/pull-changes-resolve-conflicts/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
复制





首页
