worktrees:finish
Use when completing work in a worktree. Handles PR creation or direct merge, worktree removal, and branch cleanup. Invoke with "/worktrees:finish" or when user mentions "finish worktree", "clean up worktree", "merge worktree", "done with worktree", or "complete worktree work".
What this skill does
# Finish Worktree
Complete work in a worktree and clean up.
## Arguments
- `--pr` - Create a pull request (default)
- `--merge` - Direct merge to target branch
- `--force` - Force cleanup with uncommitted changes
## Pre-Completion Checklist
Before finishing, verify:
- [ ] All changes committed
- [ ] Tests passing
- [ ] Branch pushed to remote
- [ ] Work reviewed (if applicable)
```bash
# Check for uncommitted changes
git status
# Run tests
npm test # or your test command
# Push if needed
git push -u origin $(git branch --show-current)
```
## Option 1: Create Pull Request (--pr)
For peer workflows and standard code review.
### Step 1: Ensure Up to Date
```bash
# Fetch latest changes
git fetch origin main
# Rebase to include latest main
git rebase origin/main
# Force push rebased branch
git push --force-with-lease
```
### Step 2: Create PR
```bash
gh pr create \
--base main \
--title "feat: <description>" \
--body "## Summary
<What this PR accomplishes>
## Changes
- <Bullet list of changes>
## Testing
<How to test>
"
```
### Step 3: After PR Merge
```bash
# Return to main project directory
cd ../.. # Exit .worktrees/<name> to project root
# Pull merged changes
git checkout main
git pull origin main
# Remove worktree
git worktree remove .worktrees/<name>
# Delete local branch if still exists (PR merge usually deletes remote)
git branch -d feature/<name> 2>/dev/null
# Prune stale references
git worktree prune
```
## Option 2: Direct Merge (--merge)
For orchestrator integration where work merges directly.
### Step 1: Switch to Target Branch
```bash
# From main project directory (not worktree)
cd /path/to/main/project
git checkout <target-branch>
```
### Step 2: Merge Worktree Branch
```bash
git merge feature/<name> --no-ff -m "Merge <description>"
```
### Step 3: Run Tests
```bash
npm test # Verify integration
```
### Step 4: Cleanup
```bash
# Remove worktree
git worktree remove .worktrees/<name>
# Delete local branch
git branch -d feature/<name>
# If pushed to remote, delete remote branch
git push origin --delete feature/<name>
# Prune stale references
git worktree prune
```
## Force Cleanup (--force)
When worktree has uncommitted changes and you want to discard:
```bash
# Force remove worktree (discards all uncommitted changes!)
git worktree remove --force .worktrees/<name>
# Delete branch
git branch -D feature/<name>
# Prune
git worktree prune
```
> **Warning:** `--force` discards uncommitted work permanently.
## Complete Cleanup Script
For cleaning up multiple worktrees:
```bash
#!/bin/bash
# cleanup-worktree.sh <worktree-name>
NAME=$1
BRANCH="feature/${NAME}"
WORKTREE=".worktrees/${NAME}"
# Check if worktree exists
if git worktree list | grep -q "$WORKTREE"; then
# Remove worktree
git worktree remove "$WORKTREE" || git worktree remove --force "$WORKTREE"
fi
# Delete local branch
git branch -d "$BRANCH" 2>/dev/null || git branch -D "$BRANCH" 2>/dev/null
# Delete remote branch if exists
git push origin --delete "$BRANCH" 2>/dev/null
# Prune
git worktree prune
echo "Cleanup complete for $NAME"
```
## Verification
After cleanup:
```bash
# Verify worktree removed
git worktree list
# Verify branch deleted
git branch -a | grep <name>
# Should show no results for worktree or branch
```
## Troubleshooting
### Cannot Remove: Uncommitted Changes
**Error:** `fatal: cannot remove worktree with uncommitted changes`
**Solutions:**
1. Commit your changes: `git add . && git commit -m "WIP"`
2. Stash changes: `git stash`
3. Force remove (loses changes): `git worktree remove --force .worktrees/<name>`
### Cannot Remove: Worktree Locked
**Error:** `fatal: worktree is locked`
**Solution:**
```bash
git worktree unlock .worktrees/<name>
git worktree remove .worktrees/<name>
```
### Branch Cannot Be Deleted
**Error:** `error: branch is not fully merged`
**Solutions:**
1. If work is merged via PR, force delete: `git branch -D feature/<name>`
2. If work needs preserving, merge first
### Stale Worktree Entry
If worktree directory was manually deleted:
```bash
git worktree prune
```
## Quick Reference
| Task | Command |
|------|---------|
| Remove worktree | `git worktree remove .worktrees/<name>` |
| Force remove | `git worktree remove --force .worktrees/<name>` |
| Delete local branch | `git branch -d feature/<name>` |
| Force delete branch | `git branch -D feature/<name>` |
| Delete remote branch | `git push origin --delete feature/<name>` |
| Prune stale entries | `git worktree prune` |
| Create PR | `gh pr create --base main` |
| Merge PR | `gh pr merge --squash --delete-branch` |
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.