prune-worktrees
Clean up worktrees for merged branches. Triggers on 'prune worktrees', 'cleanup worktrees', 'remove merged worktrees'.
What this skill does
# Prune Worktrees
Clean up worktrees whose branches have been merged on GitLab or GitHub.
## On Skill Load
Run the cleanup check automatically:
```bash
# 1. Detect remote type (GitLab or GitHub)
REMOTE_URL=$(git remote get-url origin)
if [[ "$REMOTE_URL" == *"gitlab"* ]]; then
CLI="glab"
elif [[ "$REMOTE_URL" == *"github"* ]]; then
CLI="gh"
else
echo "Unknown remote type: $REMOTE_URL"
exit 1
fi
# 2. List all worktrees (not just .git/checkouts/)
git worktree list
```
## Detection Logic
Use `git worktree list` to find all worktrees regardless of location. Skip the main worktree (first entry).
For each non-main worktree:
1. Get the path and branch from `git worktree list`
2. Check if a merged MR/PR exists for that branch:
- **GitLab:** `glab mr list --merged --source-branch <branch>`
- **GitHub:** `gh pr list --state merged --head <branch>`
3. If merged, mark for cleanup
Also check the **current worktree** - if we're on a branch that's been merged, flag it.
## Output Format
Present findings to user:
```
Worktree Cleanup Check
======================
Merged (safe to remove):
/path/to/feature-123 (branch: feature-123, MR !45 merged)
/path/to/fix-bug (branch: fix-bug, PR #67 merged)
Not merged (keep):
/path/to/wip-stuff (branch: wip-stuff, no merged MR/PR)
Dirty (has uncommitted changes):
/path/to/dirty-one (branch: dirty-one, has uncommitted changes)
```
## Cleanup Commands
After user confirms, remove merged worktrees:
```bash
# For each confirmed worktree
git worktree remove <path>
# Prune stale worktree references
git worktree prune
# Optionally delete the remote branch if still exists
git push origin --delete <branch>
```
## Safety Rules
- **NEVER auto-delete** - always show list and ask for confirmation
- **NEVER delete worktrees with uncommitted changes** without warning
- **Check for uncommitted changes** before removing:
```bash
git -C <worktree-path> status --porcelain
```
If output is non-empty, warn user about uncommitted changes
- **Skip the main worktree** - never offer to remove the primary checkout
## Script
```bash
#!/bin/bash
set -euo pipefail
REMOTE_URL=$(git remote get-url origin 2>/dev/null || echo "")
# Detect CLI
if [[ "$REMOTE_URL" == *"gitlab"* ]]; then
CLI="glab"
elif [[ "$REMOTE_URL" == *"github"* ]]; then
CLI="gh"
else
echo "Error: Cannot detect GitLab or GitHub from remote: $REMOTE_URL"
exit 1
fi
echo "Checking worktrees for merged branches..."
echo
MERGED=()
UNMERGED=()
DIRTY=()
FIRST=true
# Parse git worktree list output: <path> <sha> [<branch>]
git worktree list | while read -r wt_path wt_sha wt_branch_raw; do
# Skip main worktree (first entry)
if $FIRST; then
FIRST=false
continue
fi
# Extract branch name from [branch] format
branch="${wt_branch_raw#[}"
branch="${branch%]}"
# Skip detached HEAD
if [[ "$branch" == "(detached" || -z "$branch" ]]; then
UNMERGED+=("$wt_path (detached HEAD)")
continue
fi
# Check for uncommitted changes
if [[ -n $(git -C "$wt_path" status --porcelain 2>/dev/null) ]]; then
DIRTY+=("$wt_path ($branch) - has uncommitted changes")
continue
fi
# Check if branch has merged MR/PR
if [[ "$CLI" == "glab" ]]; then
merged=$($CLI mr list --merged --source-branch "$branch" 2>/dev/null | head -1)
else
merged=$($CLI pr list --state merged --head "$branch" 2>/dev/null | head -1)
fi
if [[ -n "$merged" ]]; then
MERGED+=("$wt_path ($branch) - $merged")
else
UNMERGED+=("$wt_path ($branch)")
fi
done
if [[ ${#MERGED[@]} -gt 0 ]]; then
echo "MERGED (safe to remove):"
for item in "${MERGED[@]}"; do
echo " $item"
done
echo
fi
if [[ ${#DIRTY[@]} -gt 0 ]]; then
echo "DIRTY (has uncommitted changes - review first):"
for item in "${DIRTY[@]}"; do
echo " $item"
done
echo
fi
if [[ ${#UNMERGED[@]} -gt 0 ]]; then
echo "NOT MERGED (keep):"
for item in "${UNMERGED[@]}"; do
echo " $item"
done
echo
fi
if [[ ${#MERGED[@]} -eq 0 ]]; then
echo "No merged worktrees to clean up."
fi
```
Run this script, then ask the user which worktrees to remove.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.