worktree-manager
# Worktree Manager Skill
What this skill does
# Worktree Manager Skill
Manages git worktrees for isolated worker environments in ralph-loop++.
## Operations
### Create Worktree
Create a new isolated worktree for a worker:
```bash
# Generate unique branch name
SESSION_ID="$1"
WORKER_NUM="$2"
WORKTREE_BASE="/var/tmp/ralph-plus-worktrees"
WORKTREE_PATH="${WORKTREE_BASE}/${SESSION_ID}/worker-${WORKER_NUM}"
BRANCH_NAME="ralph-plus/${SESSION_ID}/worker-${WORKER_NUM}"
# Create base directory
mkdir -p "$(dirname "$WORKTREE_PATH")"
# Create worktree with new branch
git worktree add -b "$BRANCH_NAME" "$WORKTREE_PATH"
# Copy environment files
for env_file in .env .env.local .env.development .env.development.local; do
if [[ -f "$env_file" ]]; then
cp "$env_file" "$WORKTREE_PATH/"
fi
done
# Copy node_modules symlink (faster than npm install)
if [[ -d "node_modules" ]]; then
ln -s "$(pwd)/node_modules" "$WORKTREE_PATH/node_modules"
fi
echo "$WORKTREE_PATH"
```
### List Worktrees
List all ralph-loop++ worktrees:
```bash
git worktree list | grep "ralph-plus"
```
### Remove Worktree
Clean up a specific worktree:
```bash
WORKTREE_PATH="$1"
BRANCH_NAME=$(git -C "$WORKTREE_PATH" rev-parse --abbrev-ref HEAD)
# Remove the worktree
git worktree remove "$WORKTREE_PATH" --force
# Delete the branch
git branch -D "$BRANCH_NAME" 2>/dev/null || true
```
### Cleanup All Session Worktrees
Remove all worktrees for a session:
```bash
SESSION_ID="$1"
WORKTREE_BASE="/var/tmp/ralph-plus-worktrees/${SESSION_ID}"
# Remove each worktree
for worktree in "$WORKTREE_BASE"/worker-*; do
if [[ -d "$worktree" ]]; then
git worktree remove "$worktree" --force 2>/dev/null || true
fi
done
# Remove base directory
rm -rf "$WORKTREE_BASE"
# Clean up branches
git branch | grep "ralph-plus/${SESSION_ID}" | xargs -I {} git branch -D {} 2>/dev/null || true
```
## Worktree Locations
- **Base**: `/var/tmp/ralph-plus-worktrees/`
- **Session**: `/var/tmp/ralph-plus-worktrees/{session_id}/`
- **Worker**: `/var/tmp/ralph-plus-worktrees/{session_id}/worker-{n}/`
## Branch Naming
- Pattern: `ralph-plus/{session_id}/worker-{n}`
- Example: `ralph-plus/rp-1704567890123/worker-1`
## Environment Handling
When creating a worktree, copy:
- `.env` - Production/default environment
- `.env.local` - Local overrides
- `.env.development` - Development settings
- `.env.development.local` - Local dev overrides
- `.env.test` - Test environment (if running tests)
## Node Modules Strategy
For Node.js projects, there are two strategies:
### Symlink (Fast, works for most cases)
```bash
ln -s "$(pwd)/node_modules" "$WORKTREE_PATH/node_modules"
```
### Full Install (Needed if dependencies might change)
```bash
cd "$WORKTREE_PATH" && npm install
```
## Error Handling
### Worktree Already Exists
```bash
if [[ -d "$WORKTREE_PATH" ]]; then
echo "Worktree already exists, removing first"
git worktree remove "$WORKTREE_PATH" --force
fi
```
### Branch Already Exists
```bash
if git show-ref --verify --quiet "refs/heads/$BRANCH_NAME"; then
echo "Branch already exists, deleting first"
git branch -D "$BRANCH_NAME"
fi
```
### Dirty Worktree on Cleanup
```bash
# Force removal even with uncommitted changes
git worktree remove "$WORKTREE_PATH" --force
```
## Usage in Ralph-Loop++
The orchestrator uses this skill to:
1. Create worktrees before spawning workers
2. Pass worktree paths to worker agents
3. Clean up all worktrees after integration complete
4. Handle recovery after crashes
## Troubleshooting
### "fatal: '$PATH' is already checked out"
Another worktree has the same branch. Use unique branch names per session/worker.
### "fatal: '$WORKTREE_PATH' is a main working tree"
Trying to remove the main repository. Check path is correct.
### Orphaned Worktrees
If worktrees exist but aren't in `git worktree list`:
```bash
git worktree prune
```
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.