Non-negotiable rules:
- Check merge readiness before merging: branch state, CI, reviews, and conflict risk.
- Create a backup point before non-trivial merges or destructive recovery.
- Validate after merging before declaring success.
- Prefer isolated worktree execution for risky or explicitly isolated merges.
- Get explicit user confirmation before destructive rollback or branch cleanup.
Git Merge Expert
Inputs
$request: PR number, source branch, target branch, merge method, rollback target, or conflict-resolution goal
Goal
Perform safe git merges by:
- assessing readiness and merge method
- isolating risk when needed
- resolving conflicts without dropping intent
- validating the result
- cleaning up or rolling back safely
Step 0: Resolve the requested merge operation
Determine whether the user wants to:
- merge a PR
- merge one branch into another
- resolve conflicts from an in-progress merge
- assess merge readiness before executing
- roll back a bad merge
- clean up merged branches
If the requested scope, merge method, or cleanup behavior is ambiguous, use AskUserQuestion
before mutating git state.
Success criteria: The source, target, merge method, and cleanup expectations are explicit.
Step 1: Assess readiness and choose the execution mode
Inspect:
- current branch and working tree state
- source and target branch topology
- PR readiness when applicable
- CI and review status when applicable
- conflict likelihood
Then choose whether to:
- proceed inline for a straightforward merge
- route to
git-merge-expert-worktree for isolated execution
Prefer the worktree specialist when:
- the user explicitly asks for worktree isolation
- the merge is risky or multi-step
- cleanup/retry safety matters more than speed
Load references/merge-strategies.md for merge-method and readiness rules.
Success criteria: The merge is either blocked, approved for inline execution, or redirected to the worktree specialist.
Step 2: Create a backup point and perform the merge
Before non-trivial merges or destructive rollback, create a backup reference such as a tag.
Then perform the requested operation:
- PR merge via
gh when appropriate
- branch merge with the selected strategy
- conflict resolution for an in-progress merge
Rules:
- do not merge with failing CI unless the user explicitly wants to override
- do not silently drop either side of a conflict
- regenerate lockfiles instead of hand-editing them
- use the smallest safe merge method that matches the request
Load references/conflict-and-rollback.md for conflict tiers and recovery patterns.
Success criteria: The merge or conflict-resolution step is complete and git state is coherent.
Step 3: Validate before cleanup or push
Validate the result with the narrowest relevant checks:
git status
- conflict-free state
- build/test/typecheck commands when appropriate
- branch topology inspection
Rules:
- do not claim success if unresolved conflicts or failing validation remain
- stop and recover before cleanup or push when validation fails
- if rollback is needed, use the recovery guidance instead of improvising
Success criteria: The merge result is validated or the failure state is clearly identified.
Step 4: Report, clean up, or roll back safely
Depending on the result:
- report the merge outcome
- comment on the PR if needed
- clean up merged branches conservatively
- roll back using the safest method for the branch type
Rules:
- prefer
git revert over git reset on shared branches
- do not delete branches unless they are confirmed merged or the user explicitly asked
- warn before destructive cleanup or force-push operations
- if the merge was delegated to the worktree specialist, report that routing clearly
Load references/conflict-and-rollback.md for rollback and cleanup rules.
Success criteria: The user can see the outcome, any cleanup performed, and the remaining git state.
Guardrails
- Do not let the model invoke this skill proactively; it mutates git history and branch state.
- Do not add
context: fork; if isolation is needed, use the worktree specialist instead.
- Do not add
paths:; this is a generic git workflow skill.
- Do not keep giant examples, command encyclopedias, or long failure catalogs inline in
SKILL.md.
- Do not merge with unresolved conflicts.
- Do not delete user branches or force-push shared branches without explicit approval.
When To Load References
references/merge-expertise.md
Use at session start for role and domain expertise.
references/merge-strategies.md
Use for merge-method selection, PR readiness checks, GitHub CLI usage, and when to route to the worktree specialist.
references/conflict-and-rollback.md
Use for conflict tiers, lockfile handling, rollback choices, and cleanup rules.
Output Contract
Report:
- the requested merge or rollback operation
- the chosen execution mode and merge strategy
- the readiness/validation status
- any conflicts resolved, backup refs created, or rollback actions taken
- the final git state and any cleanup performed
1---
2name: git-merge-expert
3version: 2.0.0
4description: |
5 Run a git merge, PR merge, conflict resolution, or rollback safely — readiness-checked and BACKED
6 UP before anything touches shared history. Assesses branch/CI/review state and conflict risk, tags
7 a backup point before non-trivial merges, resolves conflicts without dropping either side
8 (regenerating lockfiles, not hand-editing), validates the result, then cleans up or rolls back —
9 routing to the worktree specialist when isolated execution is safer. Never claims success with
10 unresolved conflicts or failing validation, prefers `git revert` over `reset` on shared branches,
11 and requires explicit confirmation before destructive rollback, force-push, or branch deletion.
12 Use only when the user explicitly asks to merge, resolve conflicts, or roll back.
13allowed-tools:
14 - AskUserQuestion
15 - Bash
16 - Read
17 - Edit
18 - Write
19 - Glob
20 - Grep
21 - Skill
22disable-model-invocation: true
23user-invocable: true
24argument-hint: "[PR number, source branch, target branch, or merge task]"
25arguments:
26 - request
27when_to_use: |
28 Use only when the user explicitly asks to merge a branch or PR, resolve git conflicts, review
29 merge readiness, or roll back a bad merge — "/git-merge-expert", "merge this branch", "resolve
30 these conflicts", "roll back that merge". Do NOT use for read-only git inspection or unrelated
31 code changes, and hand off to the worktree specialist (git-merge-expert-worktree) when the merge
32 should run in an isolated worktree; explicit-user-only, confirm before destructive cleanup.
33metadata:
34 source: https://skillmd.com/skills/ulpi-io/git-merge-expert
35---
36
37<EXTREMELY-IMPORTANT>
38This skill mutates git state and must stay disciplined.
39
40Non-negotiable rules:
411. Check merge readiness before merging: branch state, CI, reviews, and conflict risk.
422. Create a backup point before non-trivial merges or destructive recovery.
433. Validate after merging before declaring success.
444. Prefer isolated worktree execution for risky or explicitly isolated merges.
455. Get explicit user confirmation before destructive rollback or branch cleanup.
46</EXTREMELY-IMPORTANT>
47
48# Git Merge Expert
49
50## Inputs
51
52- `$request`: PR number, source branch, target branch, merge method, rollback target, or conflict-resolution goal
53
54## Goal
55
56Perform safe git merges by:
57
58- assessing readiness and merge method
59- isolating risk when needed
60- resolving conflicts without dropping intent
61- validating the result
62- cleaning up or rolling back safely
63
64## Step 0: Resolve the requested merge operation
65
66Determine whether the user wants to:
67
68- merge a PR
69- merge one branch into another
70- resolve conflicts from an in-progress merge
71- assess merge readiness before executing
72- roll back a bad merge
73- clean up merged branches
74
75If the requested scope, merge method, or cleanup behavior is ambiguous, use `AskUserQuestion`
76before mutating git state.
77
78**Success criteria**: The source, target, merge method, and cleanup expectations are explicit.
79
80## Step 1: Assess readiness and choose the execution mode
81
82Inspect:
83
84- current branch and working tree state
85- source and target branch topology
86- PR readiness when applicable
87- CI and review status when applicable
88- conflict likelihood
89
90Then choose whether to:
91
92- proceed inline for a straightforward merge
93- route to `git-merge-expert-worktree` for isolated execution
94
95Prefer the worktree specialist when:
96
97- the user explicitly asks for worktree isolation
98- the merge is risky or multi-step
99- cleanup/retry safety matters more than speed
100
101Load `references/merge-strategies.md` for merge-method and readiness rules.
102
103**Success criteria**: The merge is either blocked, approved for inline execution, or redirected to the worktree specialist.
104
105## Step 2: Create a backup point and perform the merge
106
107Before non-trivial merges or destructive rollback, create a backup reference such as a tag.
108
109Then perform the requested operation:
110
111- PR merge via `gh` when appropriate
112- branch merge with the selected strategy
113- conflict resolution for an in-progress merge
114
115Rules:
116
117- do not merge with failing CI unless the user explicitly wants to override
118- do not silently drop either side of a conflict
119- regenerate lockfiles instead of hand-editing them
120- use the smallest safe merge method that matches the request
121
122Load `references/conflict-and-rollback.md` for conflict tiers and recovery patterns.
123
124**Success criteria**: The merge or conflict-resolution step is complete and git state is coherent.
125
126## Step 3: Validate before cleanup or push
127
128Validate the result with the narrowest relevant checks:
129
130- `git status`
131- conflict-free state
132- build/test/typecheck commands when appropriate
133- branch topology inspection
134
135Rules:
136
137- do not claim success if unresolved conflicts or failing validation remain
138- stop and recover before cleanup or push when validation fails
139- if rollback is needed, use the recovery guidance instead of improvising
140
141**Success criteria**: The merge result is validated or the failure state is clearly identified.
142
143## Step 4: Report, clean up, or roll back safely
144
145Depending on the result:
146
147- report the merge outcome
148- comment on the PR if needed
149- clean up merged branches conservatively
150- roll back using the safest method for the branch type
151
152Rules:
153
154- prefer `git revert` over `git reset` on shared branches
155- do not delete branches unless they are confirmed merged or the user explicitly asked
156- warn before destructive cleanup or force-push operations
157- if the merge was delegated to the worktree specialist, report that routing clearly
158
159Load `references/conflict-and-rollback.md` for rollback and cleanup rules.
160
161**Success criteria**: The user can see the outcome, any cleanup performed, and the remaining git state.
162
163## Guardrails
164
165- Do not let the model invoke this skill proactively; it mutates git history and branch state.
166- Do not add `context: fork`; if isolation is needed, use the worktree specialist instead.
167- Do not add `paths:`; this is a generic git workflow skill.
168- Do not keep giant examples, command encyclopedias, or long failure catalogs inline in `SKILL.md`.
169- Do not merge with unresolved conflicts.
170- Do not delete user branches or force-push shared branches without explicit approval.
171
172## When To Load References
173
174- `references/merge-expertise.md`
175 Use at session start for role and domain expertise.
176
177- `references/merge-strategies.md`
178 Use for merge-method selection, PR readiness checks, GitHub CLI usage, and when to route to the worktree specialist.
179
180- `references/conflict-and-rollback.md`
181 Use for conflict tiers, lockfile handling, rollback choices, and cleanup rules.
182
183## Output Contract
184
185Report:
186
1871. the requested merge or rollback operation
1882. the chosen execution mode and merge strategy
1893. the readiness/validation status
1904. any conflicts resolved, backup refs created, or rollback actions taken
1915. the final git state and any cleanup performed