3 +description: "Use when planning or performing a pull, sync, merge, or rebase with upstream, especially in dirty repositories with conflicts, submodules, or worktrees."
8 +Synchronize local work with upstream safely.
12 +- A request to make a plan authorizes inspection only.
13 +- A request to pull, sync, merge, or rebase authorizes safe, reversible local execution.
14 +- Fetch only the required upstream state. Never push.
15 +- Preserve all local work. Unknown disposition blocks execution.
16 +- Decide obvious mechanics and conflict outcomes autonomously.
17 +- When intent, history, or a lossless path is unclear, ask one blocker at a time with evidence, consequences, and a recommendation; continue after the answer.
18 +- Use generic concepts in reasoning and reports. Use native terminology only for exact evidence or actions.
20 +Read [nested repository risks](references/nested-repositories.md) when submodules, nested repositories, or linked workspaces are present.
24 +1. **Resolve intent**
25 + - Distinguish the configured tracking upstream from an integration target.
26 + - Explicit target wins. A plain pull uses the configured tracking upstream.
27 + - Derive integration strategy from explicit intent, repository policy, then effective configuration. Ask if still ambiguous.
29 +2. **Inspect before changing**
30 + - Discover the repository, related workspaces, and recursive submodules.
31 + - Read instructions for every affected scope.
32 + - Inspect active operations, conflicts, locks, workspace collisions, local work, recovery points, local history, and divergence.
33 + - Refresh only the required target state.
35 +3. **Design the integration**
36 + - Partition dirty work into logical chunks: intent first, dependency cohesion second, conflict isolation third.
37 + - Prefer coherent checkpoint commits. Recommend a temporary snapshot only when work cannot sensibly be committed.
38 + - Compare local and incoming intent. Forecast overlapping paths and semantic conflicts.
39 + - Order repositories and chunks by dependency.
40 + - Plan recovery, verification, and recovery-point cleanup.
42 +4. **Resolve blockers**
43 + - Resolve evident choices without interruption.
44 + - Ask only when plausible outcomes differ semantically or no lossless route is clear.
45 + - Tests validate a resolution; they do not decide intent.
47 +5. **Act when authorized**
48 + - Create the planned recovery points and dirty-work snapshots.
49 + - Apply checkpoint chunks and integrate in dependency order.
50 + - Resolve obvious conflicts, verify them, and continue.
51 + - Stop only for a blocker or unsafe state. Never push.
53 +6. **Verify and finish**
54 + - Run structural checks, targeted checks for each resolution, then repository-prescribed checks.
55 + - Repair clear integration mistakes. Report unrelated or pre-existing failures without expanding scope.
56 + - Keep rollback references until every repository matches the plan, local work is accounted for, verification passes, and the result is acknowledged.
57 + - Before cleanup, check final state once more.
61 +Stay terse. Expand only blockers and predicted conflicts.
64 +2. Blockers, when present
69 +7. Verification and rollback
71 +A plan is complete when action requires following it, not redesigning intent, preservation, ordering, resolution, verification, or rollback.