mcpField
W
worktree-merge

worktree-merge

github.com/coleam00Development722211 installsUpdated 3w ago
Repository

About worktree-merge

worktree-merge is a skill that integrates multiple feature branches through one temporary integration branch, merging into the original branch only after validation passes. For local branch integration, it detects validation commands from repository configuration and stops on conflicts or test failures.

Key features

  1. 01Integrates multiple branches through one temporary branch
  2. 02Merges branches in the supplied order
  3. 03Detects validation commands from repository and CI configuration
  4. 04Runs tests after each merge and performs full validation
  5. 05Provides rollback and cleanup steps on failure

Use cases

  1. 01Integrate multiple feature branches locally
  2. 02Check test results after each branch merge
  3. 03Update the current branch after full validation passes
  4. 04Recover step by step after a test failure or conflict

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/coleam00/skills --skill worktree-merge

After installing, type/worktree-mergein Claude Code to confirm it loaded.

Details

From the project README

Worktree Merge

Integrate any number of feature branches into your working branch through a single throwaway integration branch, so nothing lands on the main line until every branch is merged and the whole suite passes. Validation commands are detected from the repo, never assumed.

Input

$ARGUMENTS is the list of branches to integrate.

  • Fewer than two → ask which branches to integrate. Don't guess.
  • Two or more → integrate them in the given order.

Detect the validation commands ONCE

Find the commands that prove this project works, preferring what CI already runs: read .github/workflows/*, a Makefile, or the manifest's test/lint scripts, and reuse those exact commands (test runner, type checker, linter). Do not hardcode pytest/mypy/pyright — use whatever this repo actually uses.

Steps

  1. Preconditions. Confirm you're at the repository root, not inside worktrees/ ([[ $(pwd) =~ /worktrees/ ]] → error). Store the current branch. Verify every branch in the list exists (git rev-parse --verify <branch>). Abort early with a clear message if any check fails.

  2. Create one integration branch off the current branch, named for the set (e.g. integration-<first>, with a short suffix if there are several — keep it filesystem-safe). This is where merges are tested; the main line stays untouched until the end.

  3. Merge each branch in order, --no-ff. After each merge, run the detected test command so a break is localized to the branch that caused it.

    • On conflict: stop, name the conflicting branch and files, and give resolution steps (resolve → git add → git commit → re-run the skill). Don't attempt automatic resolution.
    • On test failure: stop, report which tests failed, and give the rollback (git checkout <original> → git branch -D <integration>).
  4. Full validation once all branches are merged: run the project's complete detected suite (tests + type checks + lint). Any failure → report it and roll back; nothing reaches the main line red.

  5. Merge the integration branch into the original branch (--no-ff), then delete the integration branch.

  6. Offer cleanup with AskUserQuestion: remove the N worktrees and delete their feature branches, or keep them. On yes, for each branch: git worktree remove worktrees/<branch> and git branch -d <branch>.

Report

  • Success: the integration branch used, each branch merged (with its post-merge test result), the full validation result, the merge into <original>, and cleanup status (worktrees kept or removed, with the manual cleanup commands if kept).
  • Failure: the step and branch that failed, the current branch state, and exact rollback commands (git checkout <original> → git branch -D <integration>), plus how to continue after fixing (re-run with the same branch list).

Notes

  • --no-ff preserves each feature branch's history.
  • The integration branch is disposable — the original branch only moves after every merge and the full suite pass.
  • Prefer opening a PR per branch when you're on a team; this skill is for fast local integration when you own the merge.

Comments

Markdown supported