Skip to content

rse/ase / plugin/skills/ase-repo-merge

ase-repo-merge

Verified

Merge 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:

    1. Set to empty, to false, and to false.

    2. Set to with any leading and trailing whitespace stripped. If is empty or contains whitespace, expand the following:

    3. Determine the checked-out branch by running the command git branch --show-current (taken exactly as given) and capturing its output into . If is current, set , otherwise set . If is empty (detached HEAD), expand the following:

    4. 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 the git commands, and only then run the command git rev-parse --verify --quiet "refs/heads/<branch/>" (with substituted). If the check or the command fails for a branch, expand the following:

    5. Determine the worktrees by running the command git worktree list --porcelain (taken exactly as given). Set to the worktree path of the entry whose branch line is refs/heads/<source/> (or to empty if there is none), and set to the worktree path of the entry whose branch line is refs/heads/<target/> (or to empty if there is none). Do not output anything.

    1. If is empty, skip this entire STEP 2, as a branch not checked out anywhere carries no uncommitted changes.

    2. Run the command git -C "<source-dir/>" status --porcelain. If its output is empty, skip the remaining items of this STEP 2.

    3. Stage all changes by running the command git -C "<source-dir/>" add --all, inspect them by running the command git -C "<source-dir/>" diff --cached, and craft a commit in the format <type/>: <summary/>, where is one of FEATURE, IMPROVEMENT, BUGFIX, UPDATE, CLEANUP, or REFACTOR and 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 add Co-Authored-By trailers to commit messages.

    4. Commit the changes by running the command git -C "<source-dir/>" commit -m "<message/>". If it fails, unstage the changes again by running the command git -C "<source-dir/>" reset --quiet and expand the following:

    5. Capture the output of the command git -C "<source-dir/>" rev-parse HEAD into . If equals , set to true, as the committed changes already landed on the target branch.

    6. Only output the following :

    1. If equals , skip this entire STEP 3, as the committed changes already landed on the target branch.

    2. If is empty, expand the following:

    3. 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:

    4. Capture the output of the command git -C "<target-dir/>" rev-parse HEAD into , 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 no MERGE_HEAD and hence cannot be aborted via git 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 command git -C "<source-dir/>" status --porcelain reports 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 .

    5. 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.

    6. 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:

    7. 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:

    8. Conclude the conflict resolution according to by running the command:

      • merge: git -C "<target-dir/>" commit --no-edit
      • squash: skip this item, as item 9 below commits.
      • rebase: git -C "<op-dir/>" -c core.editor=true rebase --continue

      If the rebase --continue stopped 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 :

    9. Land the operation according to :

      • merge: nothing to do, as the merge commit already exists.

      • squash: if the command git -C "<target-dir/>" diff --cached --quiet succeeds, 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 command git -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 command git -C "<target-dir/>" switch "<target/>". Then fast-forward the target branch onto the rebased source branch by running the command git -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.

    1. If equals , skip this entire STEP 4.

    2. 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:

    1. If is not empty and differs from , remove the worktree of the source branch by running the command git worktree remove "<source-dir/>".

    2. Delete the merged source branch by running the command git -C "<target-dir/>" branch -d "<source/>", or, for squash, whose source branch Git never considers merged, by running the command git -C "<target-dir/>" branch -D "<source/>".

    3. If a command fails, only output the following and continue, as the merge itself succeeded:

  1. Only output the following :

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 implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
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 fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
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 alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall