JSPM

@rowing-tech/worktree-manager

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q24281F
  • License MIT

A manager for setting up git worktrees in any repository - Built at Rowing.tech

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!

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes with tests: pnpm test
  4. Ensure types are correct: pnpm type-check
  5. 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