Package Exports
- @rowing-tech/worktree-manager
- @rowing-tech/worktree-manager/dist/cli.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rowing-tech/worktree-manager) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Worktree Manager ๐
Manage git worktrees in any repository with one command. Work on multiple branches simultaneously without switching contexts.
Built with โค๏ธ at Rowing.tech
โ ๏ธ Important Safety Notice
Before using this tool:
- ๐ก๏ธ Make a backup of your repository before running
- ๐งช Test first in a non-production folder or repository
- ๐ค Ensure all changes are pushed to your remote repository
- โ๏ธ This tool manipulates files and git configuration extensively
While thoroughly tested with 35 test cases, we strongly recommend experimenting in a safe environment first.
Quick Start
Run from anywhere (no need to be in a git repo):
npx @rowing-tech/worktree-manager@latest
The interactive tool will:
- ๐ Ask for your repository path or URL if not in a git repo
- ๐ฅ Clone repositories automatically from GitHub, GitLab, Bitbucket URLs
- ๐ฏ Detect available branches automatically
- ๐ Offer conversion options (convert existing repo vs tools-only)
- โ Create selected worktrees automatically
- ๐ Set up shared environment and scripts
New in v3.1.1: Effect.js Architecture & Best Practices ๐ฅ
- โก Effect.js Architecture - Built with Effect.js for robust functional programming patterns
- ๐๏ธ Platform Services - Uses @effect/platform for standard file system operations
- ๐ก๏ธ Type-Safe Operations - Schema validation and branded types for bulletproof code
- ๐ Composable Effects - Parallel operations, resource management, and structured concurrency
- ๐ฏ Enhanced Error Handling - Detailed error context with recovery suggestions
- ๐งช Comprehensive Testing - 35 tests including integration and scenario testing with realistic CLI simulation
Previous Features:
- ๐ฅ Automatic git cloning - paste any GitHub/GitLab URL and it clones automatically
- ๐ Universal repository support - works with GitHub, GitLab, Bitbucket, and more
- ๐ Enhanced security - input sanitization prevents shell injection attacks
- ๐ก๏ธ Environment protection - existing .env files are never overwritten
- ๐จ Better error handling - specific error messages with actionable solutions
- โ Prerequisite validation - checks for required tools before starting
- ๐งน Automatic cleanup - removes partial files if setup fails
- ๐ก๏ธ Safe branch filtering - validates branch names for security
- ๐จ Interactive prompts for better user experience
- ๐ง Smart repository detection - works from any directory
- ๐๏ธ Automatic conversion of existing repos to worktree structure
What You Get
- ๐ No More Context Switching: Change branches by changing directories
- ๐ Shared Environment: Single
.env
file across all worktrees - ๐ Parallel Development: Run multiple branches simultaneously
- โ๏ธ IDE Configuration Sync: Copy settings between worktrees (VS Code, Cursor, Claude)
- ๐ฆ Dependency Isolation: Separate node_modules for each branch
- ๐ฏ Smart Setup: Interactive prompts guide you through the process
- ๐ง Flexible Installation: Works from any directory, no pre-setup needed
After Setup
1. Create Your Environment File
cp .env.sample .env
# Edit .env with your actual values
Note: If you already have a
.env
file, the tool will never overwrite it. Your existing environment variables are always protected.
2. Create Your First Worktree
# For main branch
./scripts/create-worktree.sh main
# For a new feature branch
./scripts/create-worktree.sh feature/my-feature main
3. Start Working
cd main/ # Switch to main branch
pnpm install && pnpm dev
# In another terminal
cd feature/my-feature/ # Switch to feature branch
pnpm install && pnpm dev
Daily Usage
# Create new feature branch
./scripts/create-worktree.sh feature/login-page main
# Work on it
cd feature/login-page/
pnpm install
pnpm dev
# Switch back to main
cd ../main/
# List all worktrees
git worktree list
# Remove old worktrees
git worktree remove feature/old-feature
Project Structure After Setup
your-repository/
โโโ .env # Shared secrets (not in git)
โโโ scripts/
โ โโโ create-worktree.sh # Creates new worktrees
โ โโโ sync-ide-config.sh # Syncs IDE configurations
โโโ main/ # Main branch worktree
โ โโโ .env โ ../.env # Symlink to shared .env
โ โโโ [your project files]
โโโ feature/
โโโ your-feature/ # Feature branch worktree
โโโ .env โ ../../.env # Symlink to shared .env
โโโ [your project files]
Advanced Features
Sync IDE Configurations
# Copy VS Code/Cursor settings between worktrees
./scripts/sync-ide-config.sh main feature/my-feature
Interactive Setup Flow
When you run the command, you'll see:
๐ Worktree Manager
==================
# If not in a git repository:
โ Not in a git repository
? Enter the path to your git repository (or git URL to clone): https://github.com/user/repo
๐ Cloning repository from https://github.com/user/repo...
โ
Repository cloned to ./repo
๐ Detected repository: my-project
๐ Location: /Users/you/my-project
? How would you like to set up worktrees?
โ Convert to worktree structure (moves current files to main/ subdirectory)
โ Just add worktree tools (keeps current structure)
๐ Available branches:
main
develop
feature/auth
? Which branches would you like to create worktrees for?
โ main
โฏ develop
โฏ feature/auth
๐ Creating worktrees...
โ
Created worktree for main
๐ Setup complete!
Ready to work! You can now:
cd main/
Requirements
- Node.js 18+ (for running the CLI)
- Git 2.5+ (for worktree support)
- curl (for git cloning operations)
Platform Support
- โ macOS & Linux: Full support
- โ Windows: Works with Git Bash or WSL
- โ CI/CD: Perfect for parallel testing workflows
Why Use Worktrees?
- No more
git stash
when switching branches - Run multiple branches simultaneously for testing
- Separate dependencies - no conflicts between branches
- Faster CI/CD - test multiple branches in parallel
- Better for large projects - avoid long build times when switching
Development
This project is built with modern tooling:
# Clone and setup
git clone https://github.com/rowing-tech/worktree-manager.git
cd worktree-manager
pnpm install
# Development commands
pnpm build # Compile TypeScript with shebang
pnpm dev # Build and run CLI with --help
pnpm dev:interactive # Build and run CLI interactively
pnpm dev:watch # Watch mode for development
pnpm test # Run tests in watch mode (optimized to avoid restarts)
pnpm test:run # Run tests once (35 tests pass in ~9 seconds)
pnpm type-check # Verify TypeScript types
Tech Stack:
- Effect.js v3.x for functional programming patterns and robust error handling
- @effect/platform for cross-platform file system operations
- TypeScript for type safety and modern JavaScript features
- Service Architecture with dependency injection and Effect.js patterns for testability
- Schema Validation with Effect.js Schema and branded types for type-safe operations
- ES Modules for modern compatibility
- Vitest for fast testing with comprehensive coverage
- Inquirer for beautiful interactive prompts (wrapped in Effect patterns)
- tsx for seamless development workflow
- Comprehensive Logging with structured LoggerService following Effect.js patterns
- Resource Management with WorkingDirectoryService for safe operations
Contributing
Found a bug or have an improvement? We welcome contributions!
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes with tests:
pnpm test
- Ensure types are correct:
pnpm type-check
- Submit a pull request
Credits
Developed by faramos at Rowing.tech - Augmenting workforce through intelligent automation, AI orchestration and custom solutions.
License
MIT - see LICENSE for details