Set up git worktrees for parallel development
Sets up git worktrees for parallel development across independent work streams
/plugin marketplace add ariaxhan/kernel-plugin/plugin install kernel@kernel-marketplaceWhen user invokes /parallelize, set up git worktrees for parallel development across independent work streams.
Parse the user's request to identify independent work streams:
Example:
USER: "Add OAuth, billing, and notifications"
STREAMS:
1. OAuth Authentication
- Files: src/auth/, models/user.py
- Branch: feature-oauth
- Scope: Large
2. Billing Integration
- Files: src/billing/, services/stripe.py
- Branch: feature-billing
- Scope: Large
3. Email Notifications
- Files: src/notifications/, workers/email.py
- Branch: feature-notifications
- Scope: Medium
If user hasn't provided enough detail, ask for clarification on:
Use AskUserQuestion to ask:
question: "How should I coordinate work across the worktrees?"
options:
1. Independent - I'll create worktrees and provide commands for you to open new terminals with Claude in each. You manually merge when done.
2. Coordinated - I'll create worktrees, spawn agents in each, monitor progress, and handle merging for you.
For each stream, create a worktree:
# Get current directory name for naming convention
PROJECT_NAME=$(basename $(pwd))
# Create worktrees (one per stream)
git worktree add -b [branch-name] ../${PROJECT_NAME}-[stream-name]
# Example:
git worktree add -b feature-oauth ../myproject-feature-oauth
git worktree add -b feature-billing ../myproject-feature-billing
git worktree add -b feature-notifications ../myproject-feature-notifications
Verify with git worktree list
Provide copy-paste commands for the user:
## Worktrees Created!
### Open New Terminals (macOS)
**Automated** (copy-paste these):
```bash
osascript -e 'tell application "Terminal" to do script "cd /path/to/worktree-1 && claude"'
osascript -e 'tell application "Terminal" to do script "cd /path/to/worktree-2 && claude"'
osascript -e 'tell application "Terminal" to do script "cd /path/to/worktree-3 && claude"'
Manual:
# Tab 1
cd /path/to/worktree-1
claude
# Tab 2
cd /path/to/worktree-2
claude
# Tab 3
cd /path/to/worktree-3
claude
Worktree 1 (feature-oauth):
Worktree 2 (feature-billing):
Worktree 3 (feature-notifications):
# Return to main worktree
cd /original/path
# Merge each branch
git checkout main
git merge feature-oauth
git merge feature-billing
git merge feature-notifications
# Push
git push origin main
Or create PRs:
git push -u origin feature-oauth
git push -u origin feature-billing
git push -u origin feature-notifications
# Then create PRs on GitHub
# Remove worktrees
git worktree remove ../myproject-feature-oauth
git worktree remove ../myproject-feature-billing
git worktree remove ../myproject-feature-notifications
# Delete branches (if merged)
git branch -d feature-oauth
git branch -d feature-billing
git branch -d feature-notifications
### 4B. Coordinated Mode Execution
Spawn agents in each worktree using Task tool:
For each stream:
subagent_type: "general-purpose"
prompt: "You are working in worktree [path] on branch [branch-name]. Your task: [specific stream tasks]
IMPORTANT: Your working directory is [worktree-path].
All file operations should be relative to this directory.
When done:
- Commit your changes
- Report completion
Do NOT merge or delete the worktree."
Example:
Task 1: OAuth Agent Directory: ../myproject-feature-oauth Branch: feature-oauth Task: Implement OAuth login flow
Task 2: Billing Agent Directory: ../myproject-feature-billing Branch: feature-billing Task: Integrate Stripe payment processing
Task 3: Notifications Agent Directory: ../myproject-feature-notifications Branch: feature-notifications Task: Set up email notification system
Monitor agents:
- Track completion status
- Handle errors/questions
- Coordinate if dependencies emerge
When all agents complete:
1. Review each branch
2. Merge in appropriate order (considering dependencies)
3. Clean up worktrees
4. Report final status
### 5. Final Verification
After setup, verify:
```bash
git worktree list # Shows all worktrees
git branch # Shows all branches
Error: Current working directory has uncommitted changes
Solution: Ask user to commit or stash first
Error: Worktree path already exists
Solution: Suggest different naming or cleanup existing
Error: Not in a git repository
Solution: Cannot use worktrees, suggest regular subagents
❌ Creating worktrees without user approval ❌ Auto-merging without review ❌ Forgetting to provide cleanup commands ❌ Not checking git status first
.claude/skills/worktree-parallelization/SKILL.md for detection criteria