Use when processing parallel PRs. Trigger with git worktree or parallel development requests.
npx claudepluginhub emasoft/emasoft-plugins --plugin emasoft-integrator-agentThis skill uses the workspace's default tool permissions.
This skill teaches you how to use git worktrees for parallel PR processing. Git worktrees allow you to work on multiple branches simultaneously in separate directories while sharing a single git repository database.
README.mdreferences/creating-worktrees-part1-standard-flow.mdreferences/creating-worktrees-part2-purpose-patterns.mdreferences/creating-worktrees-part3-port-allocation.mdreferences/creating-worktrees-part4-environment-setup.mdreferences/creating-worktrees-part5-commands-checklist.mdreferences/creating-worktrees-part6-troubleshooting.mdreferences/creating-worktrees.mdreferences/cross-platform-support.mdreferences/docker-worktree-testing-part1-setup.mdreferences/docker-worktree-testing-part2-best-practices.mdreferences/docker-worktree-testing.mdreferences/merge-safeguards-part1-core-concepts.mdreferences/merge-safeguards-part1-fundamentals.mdreferences/merge-safeguards-part2-advanced.mdreferences/merge-safeguards-part2-usage-workflows.mdreferences/merge-safeguards-part3-validation-advanced.mdreferences/merge-safeguards-part4-automation-practices.mdreferences/merge-safeguards-part5-troubleshooting.mdreferences/merge-safeguards.mdCreates isolated Git worktrees for parallel development, risky refactoring, or multi-feature work without branch switching or conflicts.
Manages Git worktrees for parallel development: create from main with .env copying, list status, switch, cleanup interactively via bash script.
Creates isolated git worktrees for parallel development without disrupting the main workspace. Includes safety verification, .gitignore checks, and directory selection. Use for feature work or PR reviews.
Share bugs, ideas, or general feedback.
This skill teaches you how to use git worktrees for parallel PR processing. Git worktrees allow you to work on multiple branches simultaneously in separate directories while sharing a single git repository database.
Before using this skill, ensure:
git --version)Use git worktrees when you need to:
Do NOT use worktrees when:
Copy this checklist and track your progress:
git --version)git fetch origin pull/<PR>/head:<branch>python scripts/eia_create_worktree.py --pr <number> --base-path /tmp/worktreespython scripts/eia_verify_worktree_isolation.py --worktree-path <path>python scripts/eia_worktree_commit_push.py --worktree-path <path> --message "<msg>"python scripts/eia_cleanup_worktree.py --worktree-path <path>CONSTRAINT 1: ABSOLUTE ISOLATION Every file write, edit, or creation MUST happen within the assigned worktree directory. Writing files outside your worktree corrupts the isolation model and causes merge conflicts.
CONSTRAINT 2: NO CONCURRENT GIT OPERATIONS Never run git operations (commit, push, fetch, rebase) in multiple worktrees simultaneously. Git's lock mechanisms can deadlock or corrupt the shared repository database.
CONSTRAINT 3: VERIFY BEFORE CLEANUP Before removing a worktree, ALWAYS verify:
CONSTRAINT 4: ONE BRANCH PER WORKTREE A branch can only be checked out in ONE worktree at a time. Attempting to checkout a branch that exists in another worktree will fail.
CONSTRAINT 5: WORKTREE PATH RULES
START: Need to work on a PR?
│
├─► Is this PR already in a worktree?
│ ├─► YES: Navigate to existing worktree
│ └─► NO: Continue below
│
├─► Is another git operation running?
│ ├─► YES: WAIT until it completes
│ └─► NO: Continue below
│
├─► Create new worktree for PR
│ ├─► Fetch PR branch from remote
│ ├─► Create worktree at designated path
│ └─► Verify worktree creation succeeded
│
├─► Work ONLY within worktree directory
│ ├─► All file operations inside worktree
│ ├─► All script executions from worktree
│ └─► Verify isolation periodically
│
├─► Ready to commit/push?
│ ├─► Verify no other git ops running
│ ├─► Commit changes in worktree
│ └─► Push to remote
│
└─► PR merged/completed?
├─► Verify all changes pushed
├─► Verify no uncommitted files
└─► Remove worktree safely
For understanding what worktrees are and how they work, see worktree-fundamentals.md:
Contents:
For implementing parallel PR processing with worktrees, see parallel-pr-workflow.md:
Contents:
For safely removing worktrees after PR completion, see worktree-cleanup.md:
Contents:
For verifying worktree integrity and isolation, see worktree-verification.md:
Contents:
This skill includes Python scripts for common worktree operations:
| Script | Purpose | When to Use |
|---|---|---|
eia_create_worktree.py | Create worktree for a PR | Starting work on a new PR |
eia_list_worktrees.py | List all active worktrees | Before creating new worktree, status check |
eia_cleanup_worktree.py | Safely remove a worktree | After PR is merged/closed |
eia_verify_worktree_isolation.py | Check for isolation violations | Before committing, periodically |
eia_worktree_commit_push.py | Commit and push changes | Ready to update remote |
Creating a worktree for PR #123:
python scripts/eia_create_worktree.py --pr 123 --base-path /tmp/worktrees
Listing all worktrees:
python scripts/eia_list_worktrees.py --repo-path /path/to/main/repo
Verifying isolation:
python scripts/eia_verify_worktree_isolation.py --worktree-path /tmp/worktrees/pr-123
Committing and pushing:
python scripts/eia_worktree_commit_push.py --worktree-path /tmp/worktrees/pr-123 --message "Fix issue"
Cleaning up a worktree:
python scripts/eia_cleanup_worktree.py --worktree-path /tmp/worktrees/pr-123
# Create worktree for PR #123
python scripts/eia_create_worktree.py --pr 123 --base-path /tmp/worktrees
# Navigate to worktree and work
cd /tmp/worktrees/pr-123
# Make changes, commit, push
# Clean up when done
python scripts/eia_cleanup_worktree.py --worktree-path /tmp/worktrees/pr-123
# Create worktrees for each PR
python scripts/eia_create_worktree.py --pr 101 --base-path /tmp/worktrees
python scripts/eia_create_worktree.py --pr 102 --base-path /tmp/worktrees
python scripts/eia_create_worktree.py --pr 103 --base-path /tmp/worktrees
# Assign each worktree to a different subagent
# Each agent works in isolation in its own directory
# Verify isolation periodically
python scripts/eia_verify_worktree_isolation.py --worktree-path /tmp/worktrees/pr-101
| Output Type | Description |
|---|---|
| Worktree Directory | New directory created at specified path containing checked-out PR branch |
| Worktree List | JSON or text output listing all active worktrees with paths and branch names |
| Verification Report | Status of isolation checks showing any files written outside worktree boundaries |
| Commit Confirmation | Success/failure message with commit hash after committing changes |
| Push Confirmation | Success/failure message indicating remote branch update status |
| Cleanup Report | Confirmation of worktree removal with any warnings about uncommitted changes |
| Error Messages | Diagnostic output when operations fail (branch conflicts, lock files, etc.) |
| Isolation Violations | List of files that were written outside the designated worktree path |
Cause: Attempting to checkout a branch that exists in another worktree.
Solution: See worktree-fundamentals.md section 1.5 for branch constraint details.
Cause: Attempting to remove a worktree with uncommitted changes.
Solution: See worktree-cleanup.md section 3.2 for handling uncommitted changes.
Cause: Isolation violation - files were written outside the worktree.
Solution: See worktree-verification.md section 4.2 for detection and remediation.
Cause: Lock file exists or path already in use.
Solution: See worktree-cleanup.md section 3.4 for handling stuck worktrees.
Cause: Concurrent git operations in multiple worktrees.
Solution: See parallel-pr-workflow.md section 2.5 for serialization strategies.
The following git worktree operations are IRREVERSIBLE and can cause data loss:
| Operation | Risk | Alternative |
|---|---|---|
git worktree remove --force | Deletes worktree even with uncommitted changes | Use git worktree remove (no --force) first |
rm -rf <worktree-path> | Bypasses git's safety checks, corrupts worktree list | Always use git worktree remove |
git worktree prune | Removes stale worktree entries | Verify with git worktree list first |
Verify you have a backup branch
git branch -a | grep backup
# If no backup, create one:
git branch backup-$(date +%Y%m%d) HEAD
Confirm with orchestrator before force operations
--force flags without explicit approvalLog the operation details
echo "$(date): Removing worktree $WORKTREE_PATH - Reason: [REASON]" >> worktree-ops.log
git status in worktree to check for uncommitted changesgit log origin/branch..HEAD to check for unpushed commitsgit worktree remove <path> (without --force)git worktree listIf worktree was removed with uncommitted changes:
# Check git reflog for recent commits
git reflog
# Recover lost commits
git cherry-pick <commit-hash>
# Check for dangling commits
git fsck --lost-found
┌─────────────────────────────────────────────────────────────────────┐
│ GIT WORKTREE QUICK REFERENCE │
├─────────────────────────────────────────────────────────────────────┤
│ CREATE: git worktree add <path> <branch> │
│ LIST: git worktree list │
│ REMOVE: git worktree remove <path> │
│ PRUNE: git worktree prune │
├─────────────────────────────────────────────────────────────────────┤
│ CRITICAL RULES: │
│ 1. ONE branch per worktree (enforced by git) │
│ 2. ALL file ops inside worktree only │
│ 3. NO concurrent git ops across worktrees │
│ 4. VERIFY before cleanup │
└─────────────────────────────────────────────────────────────────────┘