From git-workflow
Use when needing to update a feature branch with the latest changes from main, especially when merge conflicts are expected or PR functionality must be preserved
How this skill is triggered — by the user, by Claude, or both
Slash command
/git-workflow:sync-mainThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Safely merge latest main into the current feature branch, resolve conflicts, and verify PR functionality is unchanged. Core principle: **snapshot before, verify after**.
Safely merge latest main into the current feature branch, resolve conflicts, and verify PR functionality is unchanged. Core principle: snapshot before, verify after.
digraph sync_main {
"Start" [shape=doublecircle];
"Uncommitted changes?" [shape=diamond];
"git stash" [shape=plaintext];
"Snapshot PR diff" [shape=box];
"git fetch origin main" [shape=plaintext];
"git merge origin/main" [shape=plaintext];
"Conflicts?" [shape=diamond];
"Resolve conflicts" [shape=box];
"Run verification" [shape=box];
"Compare PR diff" [shape=box];
"Diff matches?" [shape=diamond];
"STOP: Investigate diff difference" [shape=octagon, style=filled, fillcolor=red, fontcolor=white];
"Unstash if needed" [shape=box];
"Done" [shape=doublecircle];
"Start" -> "Uncommitted changes?";
"Uncommitted changes?" -> "git stash" [label="yes"];
"Uncommitted changes?" -> "Snapshot PR diff" [label="no"];
"git stash" -> "Snapshot PR diff";
"Snapshot PR diff" -> "git fetch origin main";
"git fetch origin main" -> "git merge origin/main";
"git merge origin/main" -> "Conflicts?" ;
"Conflicts?" -> "Resolve conflicts" [label="yes"];
"Conflicts?" -> "Run verification" [label="no"];
"Resolve conflicts" -> "Run verification";
"Run verification" -> "Compare PR diff";
"Compare PR diff" -> "Diff matches?" ;
"Diff matches?" -> "Unstash if needed" [label="yes"];
"Diff matches?" -> "STOP: Investigate diff difference" [label="no"];
"Unstash if needed" -> "Done";
}
git status
# If dirty:
git stash --include-untracked
Save what your PR changes relative to main before merging:
git diff origin/main...HEAD > /tmp/pr-diff-before.patch
git diff --stat origin/main...HEAD > /tmp/pr-stat-before.txt
The three-dot diff (...) shows only your branch's changes, excluding main's. This is your baseline.
git fetch origin main
git merge origin/main
If no conflicts, skip to step 5.
For each conflicted file:
# List conflicts
git diff --name-only --diff-filter=U
# For each file, understand both sides:
git show origin/main:<path> # What main changed
git show HEAD:<path> # What your branch has (pre-merge HEAD)
git log --oneline origin/main...HEAD -- <path> # Commits touching this file from both sides
Resolution strategy:
After resolving each file:
git add <path>
Finalize:
git commit # Accept default merge message
Run the project's full quality suite:
make check-all
make test
Fix any failures — they indicate conflict resolution errors or API changes in main that need adaptation.
git diff origin/main...HEAD > /tmp/pr-diff-after.patch
git diff --stat origin/main...HEAD > /tmp/pr-stat-after.txt
# Compare:
diff /tmp/pr-stat-before.txt /tmp/pr-stat-after.txt
What to check:
If the stat diff shows unexpected changes, compare the full patches:
diff /tmp/pr-diff-before.patch /tmp/pr-diff-after.patch
Investigate any differences before proceeding.
# Only if you stashed in step 1:
git stash pop
| Step | Command | Purpose |
|---|---|---|
| Safeguard | git stash --include-untracked | Protect uncommitted work |
| Snapshot | git diff origin/main...HEAD > /tmp/pr-diff-before.patch | Baseline PR changes |
| Fetch | git fetch origin main | Get latest main |
| Merge | git merge origin/main | Integrate main |
| Conflicts | git diff --name-only --diff-filter=U | List conflicted files |
| Context | git show origin/main:<path> | See main's version |
| Verify | make check-all && make test | Quality gates |
| Compare | diff /tmp/pr-stat-before.txt /tmp/pr-stat-after.txt | Confirm PR intact |
| Mistake | Fix |
|---|---|
| Merging without snapshotting PR diff first | Always capture origin/main...HEAD diff before merge |
| Resolving conflicts by blindly accepting "ours" or "theirs" | Understand both sides; combine intent |
| Skipping tests after merge | Conflicts may compile but break logic |
| Force-pushing after merge | Never force-push; merge commits are additive |
| Not comparing before/after PR diff | The whole point is preserving PR functionality |
npx claudepluginhub himmelreich-it/agentic-development --plugin git-workflowGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.