wt-merge
Squash-merge the current branch's PR, clean up the worktree, return to main, and report remaining worktree status
What this skill does
# Merge Worktree
**Announce at start:** "I'm using the wt-merge skill to squash-merge and
clean up."
## Context
- **Current directory:** !`pwd`
- **Current branch:** !`git branch --show-current`
- **Worktrees:** !`git worktree list --porcelain`
- **Working tree status:** !`git status --porcelain`
- **Unpushed commits:** !`git rev-list '@{u}..HEAD' 2>/dev/null || echo NO_UPSTREAM`
- **PR info:** !`gh pr view --json number,url,state,title 2>&1 || echo NO_PR`
## Decision Flowchart
```mermaid
flowchart TD
A[Preconditions] -- fail --> STOP
A -- pass --> B[Merge PR]
B --> C[Cleanup + update main]
C --> D[Report]
```
## Preconditions
Only two checks before proceeding — everything else fails naturally with clear
errors from `gh pr merge`.
| Check | How to detect | Action |
|---|---|---|
| Uncommitted changes | Working tree status is non-empty | STOP — tell user to commit or stash |
| Unpushed commits | Output shows commit SHAs or `NO_UPSTREAM` | Run `git push -u origin HEAD`, then continue |
## Variables
Extract from context above:
| Variable | Source |
|---|---|
| `{NUMBER}` | PR number from PR info |
| `{MAIN_WORKTREE}` | Path of the first entry in the worktree list (the main worktree) |
| `{WORKTREE_PATH}` | Current directory (the feature worktree being removed) |
| `{BRANCH}` | Current branch name |
## Steps
### Step 1: Merge
```bash
gh pr merge {NUMBER} --squash
```
Use the PR number from context. Do NOT use `--delete-branch` (it tries to switch
branches locally, which fails when the default branch is already checked out in
the main worktree). Branch cleanup is handled in Step 2.
If this fails, STOP and show the error to the user.
### Step 2: Cleanup + update main
**CRITICAL:** This MUST be a **single Bash invocation**. After `worktree remove`
deletes {WORKTREE_PATH}, the shell's CWD no longer exists and ALL subsequent
Bash tool calls will fail. Every command uses `git -C` to operate from
{MAIN_WORKTREE} regardless of the shell's CWD state.
Do NOT split these into separate Bash calls. Do NOT remove or reorder commands.
```bash
git -C {MAIN_WORKTREE} worktree remove --force {WORKTREE_PATH}; git -C {MAIN_WORKTREE} worktree prune; git -C {MAIN_WORKTREE} branch -D {BRANCH} 2>/dev/null; git -C {MAIN_WORKTREE} fetch --prune && git -C {MAIN_WORKTREE} pull --ff-only; echo "===REMAINING WORKTREES==="; git -C {MAIN_WORKTREE} worktree list
```
Commands are joined with `;` (continue regardless of errors) except `fetch && pull`
which are dependent. Individual failures are tolerated — the branch or worktree
directory may already be gone.
### Step 3: Report
Parse the output from Step 2. Everything after `===REMAINING WORKTREES===` is
the current worktree list.
Summarize:
- PR was squash-merged (include title and URL from context)
- Worktree was removed
- Main branch was updated (or note if ff-only failed based on Step 2 output)
- List remaining worktrees from Step 2 output
Then tell the user: **"The current directory has been deleted. Please close this
session and open a new one from a valid directory."**
Do NOT run any further Bash commands or offer follow-up actions — the shell is
broken because the CWD was deleted with the worktree.
## Red Flags
**Never:**
- Remove a worktree without merging first
- Delete worktrees the user didn't confirm
- Split Step 2 into multiple Bash calls
- Run Bash commands after Step 2 completes (CWD no longer exists)
**Always:**
- Use `git -C {MAIN_WORKTREE}` for all git commands (never `cd`)
- Keep all post-merge operations in a single Bash invocation
- Tolerate errors during cleanup (worktree remove, branch delete)
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.