/empire-git:worktree-merge <branch> --into <target> [--no-close] [--ff]from empire-git
Merges a git worktree's branch into a target branch using git merge with --no-ff default. Useful for combining sub-feature branches or batching fixes before creating a PR.
Ships in empire-git. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Merge a worktree's branch into a target branch. This is always a real git merge — the target is a local branch where the worktree's commits get folded in.
User input: $ARGUMENTS
If currently inside a worktree (not the main working tree):
If $ARGUMENTS specifies a branch name or worktree path:
git worktree list --porcelain.If neither:
git worktree list and ask the user which one to merge.Record the worktree path and branch name for subsequent steps.
The target is where the source branch's commits will be merged into.
If --into <target> is in the arguments: use that branch.
If no target is specified: ask the user which branch to merge into. Common choices:
main — the default branchfeat/auth when merging feat/auth-nav)The target branch must be checked out somewhere — either in the main working tree or in another worktree. Find it:
git worktree list --porcelain
If the target branch isn't checked out anywhere, check it out in the main working tree first.
git -C "<source-worktree-path>" status --porcelain
If there are uncommitted changes, stop and tell the user:
This worktree has uncommitted changes. Please commit them first (e.g., run
/commit), then re-run/empire-git:worktree-merge.
git -C "<source-worktree-path>" log --oneline <target>..<source-branch>
If there are no commits ahead of the target, stop:
Branch
<source>has no new commits relative to<target>. Nothing to merge.
Default merge mode: --no-ff (preserves branch history as a merge commit, easier to read and revert).
If --ff was in $ARGUMENTS, omit --no-ff and let git fast-forward when possible. Use this for rebase-only or linear-history teams.
# Default
git -C "<target-worktree-path>" merge "<source-branch>" --no-ff
# With --ff
git -C "<target-worktree-path>" merge "<source-branch>"
If your team forbids merge commits entirely, this skill is the wrong tool — use git rebase directly in the source worktree, then worktree-close --push.
If merge conflicts occur:
git -C "<target-worktree-path>" diff --name-only --diff-filter=U
/empire-git:worktree-close on the source worktree when ready.On success, print:
Merged '<source-branch>' into '<target-branch>'.
If --no-close was in the arguments, skip this step and just print the result. The user may want to keep the source worktree around for further work.
Otherwise, present the same cleanup options as /empire-git:worktree-close:
After a successful merge, default to option 2 — the branch's commits are now in the target, so the source branch has served its purpose.
Run the chosen option as a single Bash call. The session may be sitting inside the source worktree, so each block resolves the main working tree once and anchors every git command with git -C "$MAIN_REPO" — nothing depends on the shell's cwd, which vanishes the instant the worktree is removed. One invocation also keeps MAIN_REPO in scope: shell variables do not survive across separate Bash calls, so the assignment must live in the same call as its uses. awk reads the path with substr($0, 10) rather than $2 so worktree paths containing spaces are not truncated.
MAIN_REPO=$(git worktree list --porcelain | awk '/^worktree / { print substr($0, 10); exit }')
git -C "$MAIN_REPO" worktree remove "<source-worktree-path>"
git -C "$MAIN_REPO" worktree prune
bash "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-registry.sh" remove "<source-worktree-path>"
git branch -d refuses to delete a branch still checked out in a worktree, so the worktree is removed first. -d is a safe delete: if it fails, the branch has commits beyond what was merged — surface that rather than force-deleting. The later lines still run, so the worktree is pruned and deregistered even when the branch is kept.
MAIN_REPO=$(git worktree list --porcelain | awk '/^worktree / { print substr($0, 10); exit }')
git -C "$MAIN_REPO" worktree remove "<source-worktree-path>"
git -C "$MAIN_REPO" branch -d "<source-branch>"
git -C "$MAIN_REPO" worktree prune
bash "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-registry.sh" remove "<source-worktree-path>"
If the registry call fails, print a warning and continue — the worktree removal already succeeded.
Print a summary of what was done.
Batching small fixes: Several small worktree branches (typo, dep bump, color tweak) merged locally into one branch before opening a single PR:
/empire-git:worktree-merge fix/typo --into feat/cleanup
/empire-git:worktree-merge fix/deps --into feat/cleanup
/empire-git:worktree-merge fix/color --into feat/cleanup
# Then open one PR from feat/cleanup
Branch decomposition: Sub-branches merged back into a parent feature branch:
/empire-git:worktree-merge feat/auth-nav --into feat/auth
/empire-git:worktree-merge feat/auth-table --into feat/auth
# Then open one PR from feat/auth
This skill does one thing: git merge. For pushing to remote, use /empire-git:worktree-close --push. For opening PRs, use the user's own PR workflow. Keeping these concerns separate avoids conflicts with existing conventions.
Merge conflicts need human judgment. When conflicts occur, clearly list the affected files and let the user decide. Attempting to auto-resolve risks silently introducing bugs.
Use git branch -d (safe delete), not -D. If the safe delete fails after a merge, something unexpected happened — surface it rather than force through.
What SKILL.md sets; muted values are Claude Code's defaults
sonnetOther plugins' skills for the same job
npx claudepluginhub marcoskichel/empire --plugin empire-git12 skills in this plugin
/activity-reportGenerate a concise activity report of the user's GitHub work over a period, grouped by area or feature instead of PR by PR. Use when user says "activity report", "weekly report", "what did I do this week", "what did I ship", "work summary", "summarize my week", "status update for my manager", "what did <user> ship", or `/empire-git:activity-report [start-date] [end-date] [author]`.
/pr-comment-replyRender the canonical reply text for a PR review comment. Use when drafting, writing, or posting a "PR comment reply", "review comment reply", "reply to this comment", "respond to this review comment", "answer the reviewer", "reply on the PR thread", or any text bound for `gh api` review-thread replies, `gh pr comment`, or a GitHub review comment box. Triggers on "reply to the comment", "answer this review comment", "respond to the reviewer", "draft a reply", "post a reply on the PR". Outputs plain text for the caller to post unchanged.
/pr-descriptionRender the canonical PR description body. Use when drafting, writing, updating, or regenerating a "PR description", "PR body", "pull request description", "pull request body", "PR summary", "PR template", "GitHub PR body", or any text bound for `gh pr create --body`, `gh pr create --body-file`, `gh pr edit --body`, `gh pr edit --body-file`, or a GitHub PR template. Triggers on "draft a PR", "write the PR", "summarize this branch for review", "regenerate PR body". MUST be invoked before any `gh pr create --body*` or `gh pr edit --body*` per empire-git rules. Outputs markdown for stdin.
/pr-mergeGate then merge a single pull request safely. Use when the user says "merge this PR", "merge the PR", "land this", "ship this PR", "merge when green". Verifies CI is green (investigates and attempts a fix when red), rebases and resolves conflicts when the branch is behind, triages unresolved review threads intelligently (resolve, fix, or ask — never blindly block), then merges and deletes the branch. Fast-forwards the local base checkout (e.g. updates `master`) when it is checked out.
/pr-merge-stackMerge an entire stack of dependent PRs bottom-up: merge the base PR, pull the base branch, rebase the next PR onto it, wait for CI, merge, repeat until the stack is empty. Use when the user says "merge the stack", "merge pr stack", "land the stack", "merge all these PRs", "merge the chain", "ship the whole stack", or names several stacked PRs to merge in order. Infers the stack from conversation; asks when it can't. Offers admin merge (skip review requirements) up front — CI must still pass either way.
/pr-review-postPost a GitHub PR review (verdict + inline comments) in one API call. Use when posting, submitting, or publishing a "PR review", "code review", "review with inline comments", "approve the PR", "request changes", or any payload bound for `gh api repos/*/pulls/*/reviews`. Triggers on "post the review", "submit the review", "publish the review comments", "approve this PR", "request changes on the PR", "leave a review". MUST be used for any review POST so comments and verdict land atomically. Never posts without the caller's confirmed verdict.