Create and manage git worktrees for parallel coding sessions with zero dead time. Use when blocked on tests, builds, wanting to work on multiple branches, context switching, or exploring multiple approaches simultaneously.
git clone https://github.com/rohitg00/pro-workflow.git--- name: parallel-worktrees description: Create and manage git worktrees for parallel coding sessions with zero dead time. Use when blocked on tests, builds, wanting to work on multiple branches, context switching, or exploring multiple approaches simultaneously. user-invocable: true --- # Parallel Worktrees Zero dead time. While one session runs tests, work on something else. ## Trigger Use when waiting on tests, long builds, exploring approaches, or needing to review and develop simultaneously. ## Quick Start **Claude Code:** ```bash claude --worktree # or claude -w (auto-creates isolated worktree) ``` **Cursor / Any editor:** ```bash git worktree add ../project-feat feature-branch # Open the new worktree folder in a second editor window ``` Both approaches create an isolated working copy where changes don't interfere with your main session. ## Claude Code Extras These features are Claude Code-specific (skip if using Cursor): - `claude -w` auto-creates and cleans up worktrees - Subagents support `isolation: worktree` in agent frontmatter - `Ctrl+F` kills all background agents (two-press confirmation) - `Ctrl+B` sends a task to background ## Workflow 1. Show current worktrees: `git worktree list` 2. Create a worktree for the parallel task. 3. Open a new editor/terminal session in the worktree. 4. When done, clean up the worktree. ## Commands ```bash git worktree list git worktree add ../project-feat feature-branch git worktree add ../project-fix bugfix-branch git worktree add ../project-exp -b experiment git worktree remove ../project-feat git worktree prune ``` ## Usage Pattern ``` Terminal 1: ~/project → Main work Terminal 2: ~/project-feat → Feature development Terminal 3: ~/project-fix → Bug fixes ``` Each worktree runs its own AI session independently. ## When to Parallelize | Scenario | Action | |----------|--------| | Tests running (2+ min) | Start new feature in worktree | | Long build | Debug issue in parallel | | Exploring approaches | Compare 2-3 simultaneously | | Review + new work | Reviewer in one, dev in other | | Waiting on CI | Start next task in worktree | ## Guardrails - Each worktree is a full working copy — changes are isolated. - Before removing a worktree, verify changes are committed: `git -C ../project-feat status` - Don't forget to clean up worktrees when done (`git worktree prune`). - Avoid editing the same files in multiple worktrees simultaneously. ## Output - Current worktree list - Created worktree path and branch - Instructions for opening a new session
1. **Initialize the Worktree Directory:** Create a dedicated directory (e.g., `~/worktrees`) to store your worktrees. This keeps your project files clean and isolated. 2. **Add Worktrees for Key Branches:** Use `git worktree add <path> <branch>` to create parallel worktrees for branches you’ll need simultaneously (e.g., `main`, feature branches, bugfix branches). 3. **Switch Contexts Instantly:** Navigate to the worktree directory for the branch you want to work on. No need to stash changes or switch branches manually. 4. **Sync Changes Across Worktrees:** Pull updates from the parent repo (`git pull --all`) to ensure all worktrees have the latest changes. 5. **Clean Up When Done:** Remove worktrees with `git worktree remove <path>` to avoid clutter. Tip: Use a script to automate setup/cleanup for repetitive workflows.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/rohitg00/pro-workflow/tree/main/skills/parallel-worktreesCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Set up a parallel git worktree workflow for [PROJECT_NAME]. Create worktrees for [BRANCH1], [BRANCH2], and [BRANCH3] in a local directory named [WORKTREE_DIR]. For each branch, pull the latest changes and switch to it. Then, outline a plan for [TASK] that can be worked on in parallel across these worktrees. Include specific commands to set up, switch between, and clean up worktrees when done.
Here’s a step-by-step workflow for managing parallel worktrees in the `ecommerce-platform` project. First, I’ll create three worktrees for the `main`, `feature/checkout-redesign`, and `bugfix/payment-failure` branches in a directory called `~/worktrees/ecommerce`. **Setup Worktrees:** ```bash mkdir -p ~/worktrees/ecommerce cd ~/projects/ecommerce-platform git worktree add ~/worktrees/ecommerce/main main git worktree add ~/worktrees/ecommerce/checkout feature/checkout-redesign git worktree add ~/worktrees/ecommerce/bugfix bugfix/payment-failure ``` **Switching Between Worktrees:** - To work on the checkout redesign: `cd ~/worktrees/ecommerce/checkout` - To debug the payment failure: `cd ~/worktrees/ecommerce/bugfix` - To pull latest changes in all worktrees: ```bash cd ~/projects/ecommerce-platform git pull --all ``` **Parallel Task Plan:** For the upcoming sprint, we’re implementing a new discount system. Here’s how to split the work: 1. **Main Worktree (`main`):** Set up the discount model and database schema. This is the foundation. 2. **Checkout Worktree (`checkout`):** Integrate the discount logic into the checkout flow UI and API. 3. **Bugfix Worktree (`bugfix`):** Write and run tests for edge cases (e.g., multiple discounts, expired codes). **Cleanup:** When the task is complete, remove the worktrees with: ```bash git worktree remove ~/worktrees/ecommerce/main git worktree remove ~/worktrees/ecommerce/checkout git worktree remove ~/worktrees/ecommerce/bugfix ``` This approach ensures you’re never blocked by long-running builds or waiting for CI. You can switch between branches instantly and keep your focus sharp.
skills-collection
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan