{"slug":"worktree-merge","title":"worktree-merge","summary":"Cleans up a worktree after its branch has been merged: removes the worktree directory and deletes the local branch. Use when the user says '/worktree-merge' or asks to clean up a merged worktree.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-25T18:00:00.716381Z","repo":{"url":"https://github.com/domengabrovsek/agent-config","stars":17,"forks":4,"license":null,"updatedAt":"2026-09-23T19:36:06Z"},"bodyHtml":"<hr>\n<h2>name: worktree-merge\ndescription: \"Cleans up a worktree after its branch has been merged: removes the worktree directory and deletes the local branch. Use when the user says '/worktree-merge' or asks to clean up a merged worktree.\"</h2>\n<p>Clean up the current worktree: $ARGUMENTS</p>\n<h2>Preconditions</h2>\n<ul>\n<li>Current <code>$PWD</code> must be inside a worktree (not the main checkout). Verify with <code>git rev-parse --git-dir != --git-common-dir</code>.</li>\n<li>The worktree's branch must be safely removable: either merged into the default branch upstream, or its upstream is <code>gone</code> (PR was merged and remote branch deleted), or the user explicitly passes <code>--force</code>.</li>\n</ul>\n<p>If the branch is not safe to remove, stop and explain what's still pending (unpushed commits, open PR, etc.). Never auto-delete unmerged work.</p>\n<h2>Steps</h2>\n<ol>\n<li><p>Capture worktree path and branch name:</p>\n<pre><code>WORKTREE=$(git rev-parse --show-toplevel)\nBRANCH=$(git rev-parse --abbrev-ref HEAD)\n</code></pre>\n</li>\n<li><p>Move out of the worktree to the main checkout (<code>cd \"$(git rev-parse --git-common-dir)/..\"</code>).</p>\n</li>\n<li><p>Remove the worktree: <code>git worktree remove \"$WORKTREE\"</code>. If it has uncommitted changes and <code>--force</code> was passed, use <code>git worktree remove --force \"$WORKTREE\"</code>.</p>\n</li>\n<li><p>Delete the local branch: <code>git branch -d \"$BRANCH\"</code> (or <code>-D</code> with <code>--force</code>).</p>\n</li>\n<li><p>Report what was cleaned up.</p>\n</li>\n</ol>\n<h2>After cleanup</h2>\n<p>If the user has more work, suggest <code>/worktree &lt;new-slug&gt;</code> for the next task rather than mutating the main checkout.</p>\n<h2>Merging parallel lanes</h2>\n<p>When several lane-mode teammates finish, merge their branches into the integration branch one at a time:</p>\n<ol>\n<li>Review each teammate's diff for correctness.</li>\n<li>Merge one branch. Resolve any conflict with <code>/resolve-conflicts</code> before merging the next.</li>\n<li>After the last merge, run the full test suite, typecheck, and lint.</li>\n<li>Prune the worktrees: <code>~/.agents/scripts/worktree-prune.sh --apply</code>. It removes only worktrees whose branch is upstream-gone or merged into the default, which is the post-merge state. Anything still active survives.</li>\n</ol>\n","files":[{"path":"SKILL.md","sizeBytes":2012,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-25T18:01:02.058163Z","sha256":"0A116BD75D639A383B9D869D55EA702C9709E957EBEDD5F70EDAFDD7DF62F833","sizeBytes":1103},"review":null,"source":{"repositoryUrl":"https://github.com/domengabrovsek/agent-config","path":"skills/worktree-merge","license":null,"commit":"48da5d0d32862b807bb1a6ad9e34824b61036e89","subtreeSha":"9458F5B0BEFB17D9592B54DADC112997737CD84984EF26A6240B98B88D703DD5","lastSyncedAt":"2026-09-25T17:59:56.400643Z"},"reviewedAt":"2026-09-25T18:20:43.788543Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/domengabrovsek/agent-config/tree/main/skills/worktree-merge"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install domengabrovsek-claude@llmmart"},{"target":"git","command":"git clone https://github.com/domengabrovsek/agent-config.git"}]}