feat: Add /parallel-work command for multi-PR development - #38
Conversation
Enable working on multiple PRs simultaneously using git worktrees with context handoff between Claude sessions. New command with three subcommands: - start: Create worktree + branch, gather context, write .parallel-context.md - list: Show all worktrees with PR/CI status in table format - cleanup: Remove worktrees for merged/closed PRs with confirmation Enhanced /status-report to show: - Active worktrees section with PR/CI status - Stacked PR detection (PRs targeting non-main branches) - Worktree-related recommendations Also created GitHub issue #37 for future tmux integration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review:
|
- Add branch existence check before worktree creation (#1) - Add explicit dirty worktree warning and confirmation in cleanup (#2) - Clarify date placeholder should be executed when writing context file (#4) - Use dynamic default branch detection for stacked PR detection (#5) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review: /parallel-work Command for Multi-PR DevelopmentThis is an excellent addition to the dotfiles that enables sophisticated parallel workflow management. The implementation is well-designed and thoughtfully integrates with existing commands. Here's my detailed feedback: ✅ Strengths1. Excellent Design
2. Strong Integration
3. User Safety
4. Documentation Quality
🔍 Code Quality Observations1. Hardcoded Default Branch (parallel-work.md:54) Issue: Hardcodes 'main' as default branch with BASE_BRANCH parameter defaulting to main, but repository could use master, develop, etc. Recommendation: Use dynamic detection like /status-report does with gh repo view to get defaultBranchRef, or fall back to git rev-parse --abbrev-ref origin/HEAD 2. Context Extraction Logic (parallel-work.md:88-97) The instruction to analyze the current conversation is clever but relies on Claude's conversation memory. This could be fragile if conversation is very long, session is resumed after interruption, or multiple context switches have occurred. Suggestion: Consider adding explicit user confirmation to review extracted context before writing to file. 3. Error Handling The commands generally assume success. Consider edge cases:
Recommendation: Add error handling instructions to check command exit codes and provide helpful error messages. 4. CI Status Parsing (parallel-work.md:230) The statusCheckRollup structure can be complex. Consider edge cases: no CI configured, multiple check suites with different statuses, pending checks vs waiting for approval. Suggestion: Add explicit parsing logic in instructions for handling null/empty CI status. 🐛 Potential Bugs1. Race Condition in cleanup (parallel-work.md:278-281) If worktree is removed between ls and status check, command could fail. Use -e checks for existence before operations. 2. Worktree Detection Logic (status-report.md:52-55) Comparing pwd to paths may fail if symlinks are involved, path is relative vs absolute, or user has cd'd to subdirectory within worktree. Fix: Use git rev-parse --show-toplevel for absolute worktree root comparison. 📊 Performance Considerations1. Sequential Git Operations (parallel-work.md:215-223) For many worktrees, sequential git -C calls could be slow. Since these are independent, suggest running in parallel using background jobs or xargs. 2. API Rate Limiting Multiple gh pr list calls in cleanup could hit rate limits with many worktrees. Consider batching: get all PRs once with state=all, then filter in memory. 🔒 Security Concerns1. Branch Name Injection User-provided BRANCH_NAME is used in paths and git commands. Malicious names with .. could escape .worktrees/ directory, or special chars could break scripts. Recommendation: Add validation to reject branch names with dangerous characters - only allow alphanumeric, dash, underscore, and forward slash. 2. Context File Contains User Data (parallel-work.md:140-166) .parallel-context.md may contain sensitive information from conversation. Already in .gitignore, but consider warning users not to commit it or adding to .git/info/exclude automatically. ✨ Enhancement Opportunities1. Workspace Validation Add health check for worktrees to detect orphaned entries where path no longer exists or is not a valid git repo. 2. Interactive Mode for start For users who prefer interactive prompts over positional args, add --interactive flag. 3. Template Support Allow users to customize .parallel-context.md template by checking for ~/.claude/templates/parallel-context.md 🧪 Test CoverageThe test plan in PR description is good, but consider edge cases: Additional test scenarios:
📝 Documentation Suggestions1. Add Troubleshooting Section Add section covering common issues like worktree already exists, permission denied, and how to clean up orphaned worktrees with git worktree prune. 2. Add Examples to CLAUDE.md Show common workflows with concrete examples of starting work on new feature, reviewing all active work, and cleaning up after merging PRs. 🎯 Final RecommendationsPriority fixes:
Overall Assessment: This is a high-quality, production-ready feature. The command is well-designed, safe by default, and fills a real workflow need. With the suggested fixes (particularly dynamic branch detection and input validation), this will be an excellent addition to the dotfiles. The integration with /status-report is particularly clever - it creates a cohesive workflow management system. Great work on the comprehensive documentation and user safety measures. Verdict: ✅ Approve with minor suggestions Review conducted following repository CLAUDE.md guidelines |
Summary
/parallel-workcommand withstart,list,cleanupsubcommands for managing git worktrees/status-reportto show active worktrees with PR/CI status and stacked PR detectionChanges
New command:
/parallel-workstart <branch> [base]- Create worktree, gather context from conversation, write.parallel-context.mdfor new sessionlist- Show all worktrees with branch, PR#, CI status, dirty/clean statecleanup- Remove worktrees for merged/closed PRs with category-based confirmationEnhanced
/status-reportOther changes
.gitignore- Added.worktrees/and.parallel-context.mdCLAUDE.md- Documented new commandRelated
Test plan
/parallel-work start test-branchand verify worktree creation/parallel-work listand verify table output/parallel-work cleanupwith mixed worktree states/status-reportand verify worktree section appears./bootstrap.sh -fto sync changes🤖 Generated with Claude Code