Install
$ agentstack add skill-marcoskichel-empire-worktree-merge ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Worktree Merge
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
Step 1 — Determine the source branch
If currently inside a worktree (not the main working tree):
- Use the current worktree's branch.
If $ARGUMENTS specifies a branch name or worktree path:
- Use that. Verify it has an associated worktree via
git worktree list --porcelain.
If neither:
- List all worktrees with
git worktree listand ask the user which one to merge.
Record the worktree path and branch name for subsequent steps.
Step 2 — Determine the target branch
The target is where the source branch's commits will be merged into.
If --into 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 branch- A parent feature branch (e.g.,
feat/authwhen mergingfeat/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.
Step 3 — Pre-flight checks
Clean working tree
git -C "" 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.
Commits to merge
git -C "" log --oneline ..
If there are no commits ahead of the target, stop:
> Branch ` has no new commits relative to `. Nothing to merge.
Step 4 — Perform the 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 "" merge "" --no-ff
# With --ff
git -C "" merge ""
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:
- List the conflicting files:
``bash git -C "" diff --name-only --diff-filter=U ``
- Report the conflicts clearly to the user.
- Stop. Merge conflicts need human judgment — auto-resolving risks silently introducing bugs. Tell the user to resolve conflicts in the target worktree, then run
/empire-git:worktree-closeon the source worktree when ready.
On success, print:
Merged '' into ''.
Step 5 — Cleanup (unless --no-close)
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:
- Remove worktree only — keeps the branch around in case it's needed
- Remove worktree + delete branch — full cleanup, since the commits now live in the target branch
- Keep everything — do nothing
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.
Option 1: remove worktree only
MAIN_REPO=$(git worktree list --porcelain | awk '/^worktree / { print substr($0, 10); exit }')
git -C "$MAIN_REPO" worktree remove ""
git -C "$MAIN_REPO" worktree prune
bash "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-registry.sh" remove ""
Option 2: remove worktree + delete branch
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 ""
git -C "$MAIN_REPO" branch -d ""
git -C "$MAIN_REPO" worktree prune
bash "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-registry.sh" remove ""
If the registry call fails, print a warning and continue — the worktree removal already succeeded.
Print a summary of what was done.
When to use this
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
Guiding principles
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.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: marcoskichel
- Source: marcoskichel/empire
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.