rse/ase / plugin/skills/ase-repo-merge
ase-repo-merge
VerifiedMerge a Git source branch, including its still uncommitted changes, into a target branch through a regular merge, a rebase with fast-forward, or a squash merge, resolving merge conflicts semantically, check that the source branch landed, and emit a MERGED, CONFLICT, or FAILED verdict. Use when the user calls to "merge", "integrate", or "land" a branch.
@${CLAUDE_SKILL_DIR}/../../meta/ase-control.md @${CLAUDE_SKILL_DIR}/../../meta/ase-skill.md @${CLAUDE_SKILL_DIR}/../../meta/ase-getopt.md
$ARGUMENTS
@${CLAUDE_SKILL_DIR}/../../meta/ase-common-resolve.md
Then only output the following and then immediately STOP processing the entire current skill:
-
-
Set to empty, to
false, and tofalse. -
Set to with any leading and trailing whitespace stripped. If is empty or contains whitespace, expand the following:
-
Determine the checked-out branch by running the command
git branch --show-current(taken exactly as given) and capturing its output into . If iscurrent, set , otherwise set . If is empty (detachedHEAD), expand the following: -
For each of the branches and , first check that it matches the regexp
^[A-Za-z0-9._/+@-]+$, which keeps it safe for being passed quoted to thegitcommands, and only then run the commandgit rev-parse --verify --quiet "refs/heads/<branch/>"(with substituted). If the check or the command fails for a branch, expand the following: -
Determine the worktrees by running the command
git worktree list --porcelain(taken exactly as given). Set to theworktreepath of the entry whosebranchline isrefs/heads/<source/>(or to empty if there is none), and set to theworktreepath of the entry whosebranchline isrefs/heads/<target/>(or to empty if there is none). Do not output anything.
-
-
-
If is empty, skip this entire STEP 2, as a branch not checked out anywhere carries no uncommitted changes.
-
Run the command
git -C "<source-dir/>" status --porcelain. If its output is empty, skip the remaining items of this STEP 2. -
Stage all changes by running the command
git -C "<source-dir/>" add --all, inspect them by running the commandgit -C "<source-dir/>" diff --cached, and craft a commit in the format<type/>: <summary/>, where is one ofFEATURE,IMPROVEMENT,BUGFIX,UPDATE,CLEANUP, orREFACTORand is a 60-80 character, imperative-mood summary without a trailing period, without Markdown formatting, and without any double-quote ("), backtick (`), dollar ($), or backslash (\) characters. Never addCo-Authored-Bytrailers to commit messages. -
Commit the changes by running the command
git -C "<source-dir/>" commit -m "<message/>". If it fails, unstage the changes again by running the commandgit -C "<source-dir/>" reset --quietand expand the following: -
Capture the output of the command
git -C "<source-dir/>" rev-parse HEADinto . If equals , set totrue, as the committed changes already landed on the target branch. -
Only output the following :
-
-
-
If equals , skip this entire STEP 3, as the committed changes already landed on the target branch.
-
If is empty, expand the following:
-
Run the command
git -C "<target-dir/>" status --porcelain. If its output is not empty, expand the following, leaving the uncommitted changes of the target untouched: -
Capture the output of the command
git -C "<target-dir/>" rev-parse HEADinto , the target branch before the merge. Then set , the worktree in which the operation runs, and , the command which undoes the in-progress operation, according to :-
merge: set and git -C "" merge --abort. -
squash: set and git -C "" reset --hard --quiet HEAD, as a squash merge records noMERGE_HEADand hence cannot be aborted viagit merge --abort(the reset is safe, as the target worktree was free of uncommitted changes before). -
rebase: the source branch has to be checked out for being rebased. If is not empty, set , and, if the commandgit -C "<source-dir/>" status --porcelainreports any output, expand the following:Otherwise, set , where the rebase temporarily checks out the source branch. In both cases set git -C "" rebase --abort, which also restores the original checkout of .
-
-
Start the operation according to by running the command:
merge:git -C "<target-dir/>" merge --no-ff --no-edit "<source/>"squash:git -C "<target-dir/>" merge --squash "<source/>"rebase:git -C "<op-dir/>" rebase "<target/>" "<source/>"
If it succeeds, continue with item 9 below.
-
Determine the conflicted files by running the command
git -C "<op-dir/>" diff --name-only --diff-filter=U. If there are none, the operation failed for another reason: run the command and expand the following: -
Resolve the conflicts semantically, never losing any change, by expanding the following:
Then expand the following:
Finally, only output the following and then immediately STOP processing the entire current skill:
-
Conclude the conflict resolution according to by running the command:
merge:git -C "<target-dir/>" commit --no-editsquash: skip this item, as item 9 below commits.rebase:git -C "<op-dir/>" -c core.editor=true rebase --continue
If the
rebase --continuestopped again with new conflicts of a further source commit, START OVER at item 7 above. If the command failed for another reason, run the command and expand the following:Otherwise, only output the following :
-
Land the operation according to :
-
merge: nothing to do, as the merge commit already exists. -
squash: if the commandgit -C "<target-dir/>" diff --cached --quietsucceeds, nothing was staged, as the changes of the source branch already are contained in the target branch, so nothing is to be committed. Otherwise, commit the squashed changes with the prepared message, listing all squashed commits, by running the commandgit -C "<target-dir/>" commit --no-edit. If it fails, run the command and expand the following:Otherwise, set to
true. -
rebase: if equals , switch it back to the target branch by running the commandgit -C "<target-dir/>" switch "<target/>". Then fast-forward the target branch onto the rebased source branch by running the commandgit -C "<target-dir/>" merge --ff-only "<source/>". If a command fails, expand the following, as the source branch is already rebased, but the target branch is unchanged:
Set to
true. -
-
-
-
If equals , skip this entire STEP 4.
-
Run the command
git merge-base --is-ancestor "<source/>" "<target/>". If it fails, the source branch did not land on the target branch, so expand the following:
-
-
-
If is not empty and differs from , remove the worktree of the source branch by running the command
git worktree remove "<source-dir/>". -
Delete the merged source branch by running the command
git -C "<target-dir/>" branch -d "<source/>", or, forsquash, whose source branch Git never considers merged, by running the commandgit -C "<target-dir/>" branch -D "<source/>". -
If a command fails, only output the following and continue, as the merge itself succeeded:
-
-
Only output the following :
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |