New advertisers: 50% off your first month with code FIRSTMONTHSee slots
devsforge avatar

create-worktrees

Git worktree command that creates checkouts for open PRs or chosen branches, including slashed names.

version
1.0.0
GitHub stars
79

What it does

  • Adds the create-worktrees command for setting up git worktrees from open PRs or specific branches
  • Handles branch names containing slashes and cleans up stale worktrees along the way
  • Supports creating custom branches for development alongside worktrees for existing ones

Creates git worktrees for all open PRs or specific branches, handling branches with slashes, cleaning up stale worktrees, and supporting custom branch creation for development.

Add marketplace

/plugin marketplace add devsforge/marketplace

Run it inside Claude Code once, then install the plugin below.

Install

/plugin install create-worktrees@devsforge-marketplace

Run it inside Claude Code after adding the marketplace.

Files

Discovered from source

Create Worktrees Command

Set up Git worktrees to work on multiple branches simultaneously without switching contexts.

Usage

/create-worktrees <branch_name> [base_branch] [path]

Examples:

/create-worktrees feature/new-auth                    # Create worktree for new branch
/create-worktrees hotfix/security-patch main         # Create from main branch
/create-worktrees feature/api-v2 develop ../worktrees/api-v2  # Custom path

What This Command Does

Creates Git worktrees that allow you to:

  1. Work on Multiple Branches: Switch between features without stashing
  2. Parallel Development: Build/test different branches simultaneously
  3. PR Reviews: Check out PRs without affecting main work
  4. Hotfix Management: Work on urgent fixes while continuing feature work
  5. Efficient Testing: Compare changes across branches easily

Git Worktrees Explained

A worktree is a linked working directory that shares the same Git repository:

project/
├── .git/                    # Main repository
├── src/                     # Main branch
└── ../worktrees/
    ├── feature-a/          # Worktree for feature-a branch
    ├── feature-b/          # Worktree for feature-b branch
    └── pr-123/             # Worktree for PR review

Benefits:

  • No need to stash changes when switching branches
  • Run tests on multiple branches simultaneously
  • Keep builds for different branches ready
  • Review PRs without disrupting current work

Creating Worktrees

Basic Worktree Creation

# Create worktree for new branch
git worktree add ../worktrees/feature-xyz -b feature/xyz

# Create from existing branch
git worktree add ../worktrees/hotfix origin/hotfix/security

# Create from specific commit
git worktree add ../worktrees/test-v1 abc123

Recommended Workflow

Step 1: Create Worktree

# Create worktree directory structure
mkdir -p ../worktrees

# Add worktree for new feature
git worktree add ../worktrees/feature-auth -b feature/user-auth

# Navigate to worktree
cd ../worktrees/feature-auth

Step 2: Work in Worktree

# Make changes
vim src/auth/login.js

# Commit normally
git add .
git commit -m "Add user authentication"
git push -u origin feature/user-auth

Step 3: List Worktrees

git worktree list
# Output:
# /path/to/project              abc123 [main]
# /path/to/worktrees/feature-auth  def456 [feature/user-auth]

Common Use Cases

1. PR Review Workflow

Review pull requests without affecting your current work:

# Fetch PR branch
gh pr checkout 123

# Or manually
git fetch origin pull/123/head:pr-123
git worktree add ../worktrees/pr-123 pr-123

# Review the code
cd ../worktrees/pr-123
npm install
npm test
npm run build

# Return to your work
cd ../../project

2. Multi-Feature Development

Work on multiple features simultaneously:

# Feature A
git worktree add ../worktrees/feature-a -b feature/payment-gateway
cd ../worktrees/feature-a
npm install
npm run dev # Runs on port 3000

# Feature B (in another terminal)
cd /path/to/project
git worktree add ../worktrees/feature-b -b feature/notification-system
cd ../worktrees/feature-b
npm install
PORT=3001 npm run dev # Runs on port 3001

3. Hotfix While Developing

Handle urgent fixes without stashing feature work:

# You're working on a feature
cd /path/to/worktrees/feature-dashboard

# Urgent hotfix needed
cd /path/to/project
git worktree add ../worktrees/hotfix-urgent -b hotfix/security-patch main
cd ../worktrees/hotfix-urgent

# Fix the issue
vim src/security/validator.js
git add .
git commit -m "Fix security vulnerability"
git push -u origin hotfix/security-patch

# Create PR for hotfix
gh pr create --title "Security patch" --base main

# Return to feature work
cd ../feature-dashboard

4. Testing Across Branches

Compare behavior across different branches:

# Main branch
cd /path/to/project
npm test

# Feature branch
cd ../worktrees/feature-new-api
npm test

# Compare results side by side

Managing Worktrees

List Worktrees

# List all worktrees
git worktree list

# Detailed view
git worktree list --porcelain

Remove Worktrees

# Remove worktree (safe - checks for uncommitted changes)
git worktree remove ../worktrees/feature-completed

# Force remove (use with caution)
git worktree remove --force ../worktrees/abandoned-feature

# Or manually delete and prune
rm -rf ../worktrees/old-feature
git worktree prune

Clean Up Stale Worktrees

# Show stale worktrees
git worktree prune --dry-run

# Remove stale references
git worktree prune

Advanced Techniques

Batch Create Worktrees for PRs

# Create worktrees for multiple PRs
gh pr list --json number,headRefName --limit 5 | \
  jq -r '.[] | "\(.number) \(.headRefName)"' | \
  while read -r pr_num branch; do
    git worktree add "../worktrees/pr-$pr_num" "$branch" 2>/dev/null || \
      git worktree add "../worktrees/pr-$pr_num" -b "$branch" "origin/$branch"
  done

Worktree with Environment Setup

# Create worktree with automatic setup
create_worktree_with_setup() {
  local branch=$1
  local path="../worktrees/$branch"

  git worktree add "$path" -b "$branch"
  cd "$path"

  # Setup environment
  npm install
  cp ../.env.example .env

  # Run initial build
  npm run build

  echo "Worktree ready: $path"
}

create_worktree_with_setup "feature/new-feature"

Shared Build Cache

Optimize build times by sharing node_modules:

# Symbolic link to shared node_modules
cd ../worktrees/feature-a
ln -s ../../project/node_modules node_modules

Best Practices

1. Organize Worktrees

Keep worktrees in a dedicated directory:

project/
├── .git/
├── src/
└── ../worktrees/
    ├── features/
    │   ├── auth/
    │   └── dashboard/
    ├── hotfixes/
    │   └── security-patch/
    └── reviews/
        ├── pr-123/
        └── pr-124/

2. Naming Conventions

Use consistent naming:

  • Features: feature-{name}
  • Hotfixes: hotfix-{issue}
  • PRs: pr-{number}
  • Tests: test-{scenario}

3. Clean Up Regularly

Remove merged worktrees:

# After PR is merged
git worktree remove ../worktrees/feature-completed
git branch -d feature/completed
git push origin --delete feature/completed

4. Documentation

Track worktrees in your project:

# Create worktree registry
echo "# Active Worktrees" > .worktrees.md
git worktree list >> .worktrees.md

Common Issues & Solutions

Issue: "Already checked out"

# Error: branch is already checked out
# Solution: Use a worktree or checkout in different location
git worktree add --detach ../worktrees/temp
cd ../worktrees/temp
git checkout feature/branch

Issue: "Worktree path exists"

# Error: directory already exists
# Solution: Remove existing directory
rm -rf ../worktrees/old-path
git worktree add ../worktrees/old-path -b new-branch

Issue: Missing dependencies

# Each worktree needs its own node_modules
cd ../worktrees/new-feature
npm install

# Or use shared cache (use with caution)
npm ci --cache ../cache

Performance Tips

  1. Limit Active Worktrees: Keep 3-5 active worktrees max
  2. Share Git Objects: Worktrees share the .git directory automatically
  3. Exclude from Backup: Add worktrees directory to backup exclusions
  4. Use Shallow Clones: For temporary review worktrees
  5. Clean Up Regularly: Remove merged or abandoned worktrees

Safety Guidelines

  1. Always commit before removing: Ensure no uncommitted changes
  2. Check worktree status: Use git worktree list before operations
  3. Avoid nested worktrees: Don't create worktrees inside worktrees
  4. Backup important work: Push branches before removing worktrees
  5. Use prune carefully: Run git worktree prune --dry-run first

Integration with IDEs

VS Code

# Open worktree in new window
code ../worktrees/feature-auth

# Or add to workspace
code --add ../worktrees/feature-auth

JetBrains IDEs

# Open worktree as new project
idea ../worktrees/feature-auth

Methodology

Git worktrees enable efficient parallel development by:

  • Context Preservation: Keep each branch's build and state separate
  • Quick Switching: Move between branches instantly (just cd)
  • Parallel Builds: Test multiple configurations simultaneously
  • Safe Experimentation: Isolated environments for each branch
  • Efficient Reviews: Check PRs without disrupting current work

From the devsforge/marketplace README

Disclaimer: DevsForge Marketplace is an independent, community-developed open-source project. It is not affiliated with, endorsed by, or officially associated with Anthropic, PBC or any of its products (including Claude, Claude Code, or the Claude API). "Claude" and "Anthropic" are trademarks of Anthropic, PBC. This project is a third-party plugin built by the community to extend Claude Code functionality.


🚀 DevsForge Marketplace

Version Plugins License Claude Code Stars

The Ultimate Plugin Ecosystem for Claude Code

161 Enterprise-Grade Plugins | 93 AI Agents | 65 Commands | 3 Super Plugins

Get Started • Browse Plugins • Documentation • Contributing


⚡ What's New in v1.2

✅ Plugin Compliance & Quality

All 161 plugins validated for Claude Code CLI

Fixes Applied:

  • 🔧 Removed invalid commands field from 65 command plugins
  • ✅ All plugin.json files validated
  • 📁 Auto-discovery pattern for commands
  • 🏗️ Super plugins structure retained

🏗️ Super Plugins (Advanced)

Multi-component platforms with hooks & MCP servers

Features:

  • 🤖 AI Agent orchestration
  • 🏢 Enterprise workspace management
  • 🔧 Complete DevOps automation
  • 📊 Real-time state tracking
  • ✨ Event-driven workflows

✨ Why DevsForge Marketplace?


🎨

Curated Quality

Every plugin manually reviewed & enterprise-tested


⚡

Production Ready

Battle-tested in real-world scenarios


🔒

Security First

Zero dependencies, fully audited code


🚀

Advanced Features

Hooks, MCP servers, automation


💯

100% Original

No copycat plugins, pure innovation


🎯 Quick Start

Installation

# 🔥 One command to rule them all
/plugin marketplace add https://github.com/devsforge/marketplace.git

# ✅ Verify installation
/plugin marketplace list

# 🎉 Expected: devsforge-marketplace (1.2.0) - 161 plugins available

Using Plugins

# 🔍 Browse available plugins
/plugin

# 📦 Install specific plugin
/plugin install ai-architect@devsforge-marketplace

# 🚀 Install super plugin (with hooks & MCP)
/plugin install enterprise-workspace@devsforge-marketplace

# 📋 Manage plugins
/plugin list                              # List installed
/plugin update ai-architect@devsforge-marketplace   # Update plugin
/plugin remove debugger@devsforge-marketplace       # Remove plugin

🎨 Featured Categories

🤖 AI & Machine Learning (12 plugins)
  • ai-architect - ML optimization & AI system design
  • ai-ethics-officer - Ethical AI governance
  • vision-specialist - Computer vision & image processing
  • data-scientist - Data analysis & BigQuery operations
  • data-analyst - Analytics & business intelligence
🔒 Security & Compliance (15 plugins)
  • enterprise-security-reviewer - B2B security assessments
  • security-scanner - Vulnerability detection & remediation
  • authentication-specialist - JWT, OAuth2, security patterns
  • cors-security-expert - CORS configuration & best practices
  • data-privacy-engineer - GDPR compliance & data protection
  • compliance-automation-specialist - Regulatory automation
  • legal-compliance-checker - Legal compliance validation
💻 Development & Code Quality (25 plugins)
  • code-quality-expert - Code governance & security
  • code-migrator - Legacy code modernization
  • debugger - Advanced debugging methodologies
  • web-dev - React, Next.js, NestJS, TypeScript
  • python-expert - Advanced Python development
  • database-expert ⚡ NEW - SQL optimization & query tuning
  • docker-specialist ⚡ NEW - Container optimization
  • git-workflow-expert ⚡ NEW - Advanced Git strategies
  • rest-api-designer ⚡ NEW - REST API best practices
  • graphql-specialist ⚡ NEW - GraphQL schema design
🔧 DevOps & Infrastructure (18 plugins)
  • devops-automator - CI/CD & infrastructure automation
  • deployment-engineer - Production deployment strategies
  • cloud-architect - Multi-cloud architecture
  • monitoring-observability-specialist - System monitoring
  • sre-reliability-engineer - Site reliability engineering
  • cost-optimizer - Cloud cost optimization
🧪 Testing & QA (10 plugins)
  • testing-orchestrator - Test automation frameworks
  • unit-test-generator - Automated test generation
  • api-quality-assurance - API testing & validation
  • performance-benchmarker - Performance testing
  • test-writer-fixer - Test creation & maintenance
📝 Documentation & Knowledge (8 plugins)
  • codebase-documenter - Comprehensive code documentation
  • technical-writer-pro - Technical documentation
  • api-docs-generator - OpenAPI/Swagger docs
  • doc-generator - Auto-documentation generation
🎨 Design & UX (8 plugins)
  • ui-designer - Beautiful, functional interfaces
  • ui-ux-engineer - React/Vue/Angular components
  • accessibility-architect - WCAG 2.1 AA compliance
  • mobile-ux-optimizer - Mobile-first experiences
  • ux-researcher - User research & journey maps
📊 Data & Analytics (7 plugins)
  • data-analyst - Analytics methodologies
  • data-scientist - SQL queries & data insights
  • database-performance-optimizer - Database optimization
  • sql-query-optimizer - Advanced SQL optimization
🏢 Enterprise & Business (12 plugins)
  • software-architect - Scalable architecture design
  • system-architect - Backend design & integration
  • b2b-project-shipper - B2B project delivery
  • customer-success-manager - Customer success ops
  • technical-sales-engineer - Technical sales support
  • pricing-packaging-specialist - Pricing strategies
🚀 Productivity & Automation (15 plugins)
  • workflow-optimizer - Workflow optimization
  • project-shipper - Launch & release management
  • sprint-prioritizer - Sprint planning & prioritization
  • experiment-tracker - Experiment tracking & analysis
  • finance-tracker - Budget & cost management
⚡ Super Plugins - Advanced (3 plugins)

🏢 enterprise-workspace

Complete workspace management platform with hooks & MCP

Components:

  • 3 Commands: workspace-init, workspace-sync, workspace-audit
  • 2 Agents: workspace-architect, compliance-auditor
  • 1 Hook: PostToolUse validation
  • 1 MCP Server: workspace-state
  • 1 Script: validate-workspace.sh

Features:

  • ✅ Architecture governance
  • ✅ Compliance tracking
  • ✅ Automated validation
  • ✅ State management

🤖 ai-studio-orchestrator

Advanced multi-agent coordination platform

Components:

  • 3 Commands: orchestrate-task, monitor-performance, optimize-workflow
  • 2 Agents: task-coordinator, performance-analyzer
  • 1 Hook: PreToolUse logging
  • 1 MCP Server: orchestrator
  • 1 Script: task-logger.sh

Features:

  • ✅ Task distribution
  • ✅ Load balancing
  • ✅ Performance analytics
  • ✅ Real-time monitoring

🔧 devops-platform

Complete DevOps automation platform

Components:

  • 3 Commands: setup-pipeline, deploy-application, manage-infrastructure
  • 2 Agents: cicd-architect, infrastructure-engineer
  • 1 Hook: PostToolUse config validation
  • 1 MCP Server: devops-state
  • 1 Script: validate-devops-config.sh

Features:

  • ✅ CI/CD pipelines (GitHub Actions, Jenkins, GitLab CI)
  • ✅ Zero-downtime deployments
  • ✅ Infrastructure as Code (Terraform, CloudFormation)
  • ✅ Security scanning

📊 Marketplace Statistics

CategoryCountDescription
🤖 Agents93AI-powered development assistants
⚡ Commands65Instant productivity tools
🚀 Super Plugins3Advanced multi-component platforms
Total161Production-ready plugins

Quality Metrics

  • ✅ Average Documentation: 250+ lines per plugin
  • ✅ Code Examples: Real-world templates included
  • ✅ Testing: Enterprise-grade validation
  • ✅ Security: Zero external dependencies
  • ✅ Maintenance: Regular updates & improvements

🏗️ Architecture

devsforge-marketplace/
├── .claude-plugin/
│   └── marketplace.json          # 📋 Marketplace registry (161 plugins)
│
├── plugins/
│   ├── agents/                    # 🤖 93 AI Agent Plugins
│   │   ├── ai-architect/
│   │   │   ├── .claude-plugin/
│   │   │   │   └── plugin.json
│   │   │   └── agents/
│   │   │       └── ai-engineer.md
│   │   ├── database-expert/       ⚡ NEW in v1.1
│   │   ├── docker-specialist/     ⚡ NEW in v1.1
│   │   ├── git-workflow-expert/   ⚡ NEW in v1.1
│   │   └── ... (90 more agents)
│   │
│   ├── commands/                  # ⚡ 65 Command Plugins
│   │   ├── api-designer/
│   │   │   ├── .claude-plugin/
│   │   │   │   └── plugin.json
│   │   │   └── commands/
│   │   │       └── api-designer.md
│   │   ├── env-validator/         ⚡ NEW in v1.1
│   │   ├── import-organizer/      ⚡ NEW in v1.1
│   │   └── ... (62 more commands)
│   │
│   └── super/                     # 🚀 3 Super Plugins
│       ├── enterprise-workspace/
│       │   ├── .claude-plugin/
│       │   │   └── plugin.json    # With hooks & MCP
│       │   ├── commands/          # Multiple commands
│       │   ├── agents/            # Multiple agents
│       │   ├── scripts/           # Automation scripts
│       │   └── servers/           # MCP servers
│       ├── ai-studio-orchestrator/
│       └── devops-platform/
│
└── README.md                      # 📖 This file

🎓 Documentation

Plugin Installation Examples

# 🤖 AI & Machine Learning
/plugin install ai-architect@devsforge-marketplace
/plugin install data-scientist@devsforge-marketplace
/plugin install vision-specialist@devsforge-marketplace

# 💻 Development Tools
/plugin install web-dev@devsforge-marketplace
/plugin install python-expert@devsforge-marketplace
/plugin install debugger@devsforge-marketplace

# 🔒 Security & Compliance
/plugin install security-scanner@devsforge-marketplace
/plugin install authentication-specialist@devsforge-marketplace
/plugin install cors-security-expert@devsforge-marketplace

# 🔧 DevOps & Infrastructure
/plugin install devops-automator@devsforge-marketplace
/plugin install docker-specialist@devsforge-marketplace
/plugin install cloud-architect@devsforge-marketplace

# ⚡ Productivity Commands
/plugin install code-review@devsforge-marketplace
/plugin install fix-github-issue@devsforge-marketplace
/plugin install pr-creator@devsforge-marketplace

# 🚀 Super Plugins (Advanced)
/plugin install enterprise-workspace@devsforge-marketplace
/plugin install ai-studio-orchestrator@devsforge-marketplace
/plugin install devops-platform@devsforge-marketplace

Marketplace Management

# 📋 List installed marketplaces
/plugin marketplace list

# 🔄 Update marketplace
/plugin marketplace update devsforge-marketplace

# 🗑️ Remove marketplace
/plugin marketplace remove devsforge-marketplace

# 🔍 Search plugins
/plugin search "security"
/plugin search "api design"

# 📊 Show plugin details
/plugin info ai-architect@devsforge-marketplace

🛠️ Troubleshooting

❌ Marketplace Not Loading

Symptoms: Marketplace doesn't appear in /plugin marketplace list

Solutions:

  1. ✅ Verify .claude-plugin/marketplace.json exists in repository root
  2. ✅ Check JSON syntax: claude plugin validate .
  3. ✅ Ensure Git repository is accessible and cloned correctly
  4. ✅ Restart Claude Code CLI after adding marketplace
❌ Plugin Installation Failures

Symptoms: Error message "Plugin not found" or installation timeout

Solutions:

  1. ✅ Verify plugin source paths are correct: ./plugins/[type]/[name]
  2. ✅ Ensure all required files exist: .claude-plugin/plugin.json, commands/*.md or agents/*.md
  3. ✅ Check network connectivity for Git-based plugin sources
  4. ✅ Try explicit version: /plugin install [name]@devsforge-marketplace@1.0.0
❌ Super Plugin Issues

Symptoms: Hooks not triggering or MCP server connection errors

Solutions:

  1. ✅ Verify ${CLAUDE_PLUGIN_ROOT} environment variable resolves correctly
  2. ✅ Check script permissions: chmod +x on Linux/Mac
  3. ✅ Ensure Node.js is installed for MCP server JavaScript files
  4. ✅ Review Claude Code logs for hook execution errors
❌ Performance Issues

Symptoms: Slow marketplace loading or plugin installation

Solutions:

  1. ✅ Check internet connection speed (GitHub clone performance)
  2. ✅ Verify available disk space (minimum 50MB required)
  3. ✅ Close unnecessary applications to free system resources
  4. ✅ Use local path installation for faster access after initial clone

🤝 Contributing

We welcome contributions! Here's how you can help:

🎯 Contributing New Plugins

  1. 🍴 Fork the repository
  2. 📁 Create plugin structure in appropriate directory (agents/, commands/, or super/)
  3. 📝 Follow plugin.json schema requirements
  4. 📖 Add comprehensive documentation (200-700+ lines recommended)
  5. 🧪 Test thoroughly with Claude Code CLI
  6. 🚀 Submit pull request with detailed description

📋 Plugin Quality Standards

  • ✅ Minimum 200 lines of documentation
  • ✅ Real-world code examples and templates
  • ✅ Phase-based methodologies
  • ✅ Best practices and anti-patterns
  • ✅ Quality metrics and KPIs
  • ✅ Business impact analysis

💡 Contributing Ideas

  • 💬 Open a GitHub Discussion with plugin proposal
  • 📝 Describe use case and business value
  • 💻 Provide examples of desired functionality
  • 🗳️ Community votes on most valuable additions

🔒 Security & Trust

⚠️ Important Disclaimer

DevsForge Marketplace is an independent, community-driven project

  • ❌ NOT affiliated with Anthropic or Claude
  • ❌ NOT officially endorsed or connected to Anthropic
  • ✅ Community maintained by open-source contributors
  • ⚠️ Use at your own risk - review plugin code before production use

Security Measures

Our Practices:

  • ✅ Security vulnerability scanning
  • ✅ Static code analysis
  • ✅ Zero third-party dependencies
  • ✅ Open source transparency
  • ✅ Community moderation
  • ✅ Regular security audits

Your Responsibilities:

  • 🔍 Review plugin source code
  • 🧪 Test in development first
  • 🐛 Report security issues on GitHub
  • 🔄 Keep plugins updated
  • 🔒 Follow least privilege principle
  • 📖 Read documentation carefully

📜 License

MIT License - See LICENSE for details

Copyright (c) 2025 DevsForge Community


🙏 Acknowledgments

Built with ❤️ by the DevsForge Community

Special thanks to:

  • 🎨 Anthropic for Claude Code CLI platform
  • 💻 All plugin contributors and testers
  • 🏢 Enterprise users providing valuable feedback
  • 🌟 Open source community for inspiration

🚀 Ready to supercharge your Claude Code experience?

Get Started Now • Browse Plugins • Contribute


DevsForge Marketplace v1.2 - The Ultimate Plugin Ecosystem for Claude Code

Made with Love Community Driven Production Ready

Details

Marketplace
devsforge/marketplace
Source
plugins/commands/create-worktrees
Author
DevsForge Community
Category
Commands
Keywords
devsforge, command, create, worktrees, development
Listed since
Apr 7, 2026

More from devsforge/marketplace

All 161

Similar to create-worktrees

More Git & Releases