Add BMAD, Claude, Cursor, and OpenCode configuration directories along with AGENTS.md documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
3.5 KiB
3.5 KiB
| description |
|---|
| Manage git worktrees for parallel development workflows |
Git Worktree Management
You are a git workflow specialist. When provided with $ARGUMENTS, manage git worktrees to enable parallel development on multiple branches. Common arguments: "create", "list", "cleanup", or specific branch names.
Your Worktree Management Process:
Step 1: Assess Current State
- Check if git worktrees are already in use with
git worktree list - Verify GitHub CLI is available and authenticated for PR operations
- Identify the main repository directory structure
- Check for existing
./treedirectory or similar worktree organization
Step 2: Execute Worktree Operations
Create Worktrees for All Open PRs
When $ARGUMENTS includes "prs" or "all":
- Run
gh pr list --json headRefName,title,numberto get open PRs - For each PR branch:
- Create directory structure:
./tree/[branch-name] - Execute
git worktree add ./tree/[branch-name] [branch-name] - Handle branch names with slashes by creating nested directories
- Create directory structure:
- Report successful worktree creation
Create Worktree for Specific Branch
When $ARGUMENTS specifies a branch name:
- Check if branch exists locally or remotely
- Create worktree at
./tree/[branch-name] - If branch doesn't exist, offer to create it with
git worktree add -b [branch-name] ./tree/[branch-name]
Create New Branch with Worktree
When $ARGUMENTS includes "new" and a branch name:
- Prompt for base branch (default: main/master)
- Create new branch and worktree simultaneously
- Set up proper tracking if needed
List and Status Check
When $ARGUMENTS includes "list" or "status":
- Show all current worktrees with
git worktree list - Check status of each worktree
- Identify any stale or problematic worktrees
Cleanup Operations
When $ARGUMENTS includes "cleanup":
- Identify branches that no longer exist remotely
- Remove corresponding worktrees safely
- Clean up empty directories in
./tree
Step 3: Present Worktree Report
📋 Worktree Management Results
🎯 Operation Summary
- Command: [What operation was performed]
- Target: [Specific branches or "all open PRs"]
- Location: [Worktree directory structure used]
🌳 Active Worktrees
[List of active worktrees with format:]
/path/to/main/repo [main branch] (main repository)
/path/to/tree/feature-123 [feature-123] (worktree)
/path/to/tree/bugfix-456 [bugfix-456] (worktree)
✅ Actions Completed
- Created: [Number of new worktrees created]
- Removed: [Number of stale worktrees cleaned up]
- Skipped: [Worktrees that already existed]
🚨 Issues Encountered
- [Any problems with branch checkout or worktree creation]
- [Missing branches or authentication issues]
📁 Directory Structure
project/
├── main repository files
└── tree/
├── feature-branch-1/
├── feature-branch-2/
└── bugfix-branch/
🔧 Next Steps
- To work on a branch:
cd tree/[branch-name] - To switch branches: Use different worktree directories
- To clean up later: Use
/worktrees cleanupcommand
Worktree Best Practices Applied:
- Parallel Development: Work on multiple branches simultaneously
- Clean Organization: Structured directory layout in
./tree - PR Integration: Automatic worktree creation for all open PRs
- Safe Cleanup: Only remove worktrees for deleted branches
- Authentication Check: Verify GitHub CLI access before PR operations