workbloom 0.1.0

A Git worktree management tool with automatic file copying and port allocation
Documentation

Workbloom

A Git worktree management tool written in Rust that automates worktree setup, file copying, and port allocation.

Features

  • ๐ŸŒฒ Easy worktree setup - Create git worktrees with a single command
  • ๐Ÿ“ฆ Automatic file copying - Copies essential files (.env, .envrc, etc.) to new worktrees
  • ๐ŸŒ Port allocation - Automatically assigns unique ports based on branch names
  • ๐Ÿงน Smart cleanup - Remove merged worktrees automatically or interactively
  • ๐ŸŽจ Beautiful output - Colored terminal output with progress indicators

Installation

# Clone the repository
git clone https://github.com/yourusername/workbloom.git
cd workbloom

# Build and install
cargo install --path .

Shell Integration (Recommended)

To automatically change to the worktree directory after setup, add this function to your .bashrc or .zshrc:

workbloom-setup() {
    local output=$(workbloom setup "$@")
    echo "$output"
    
    # Extract the worktree path and change to it
    local worktree_path=$(echo "$output" | grep "๐Ÿ“ Worktree location:" | sed 's/.*: //')
    if [ -n "$worktree_path" ] && [ -d "$worktree_path" ]; then
        cd "$worktree_path"
        echo "๐Ÿ“‚ Changed to worktree directory: $(pwd)"
    fi
}

# Then use: workbloom-setup feature/my-feature

Usage

Setup a new worktree

# Setup and start a new shell in the worktree directory (default)
workbloom setup feature/my-new-feature

# Setup without starting a shell
workbloom setup feature/my-new-feature --no-shell

This will:

  1. Create a new worktree for the branch (creating the branch if it doesn't exist)
  2. Copy required files from the main repository (.env, .envrc, etc.)
  3. Setup direnv if available
  4. Write port allocations to .env file
  5. Display allocated ports for the worktree
  6. Start a new shell in the worktree directory (unless --no-shell is used)

Clean up worktrees

# Remove merged worktrees (default)
workbloom cleanup

# Remove worktrees matching a pattern
workbloom cleanup --pattern "feature/old-"

# Interactive cleanup
workbloom cleanup --interactive

# Show merge status of all worktrees
workbloom cleanup --status

Configuration

By default, Workbloom copies the following files to new worktrees:

  • .envrc
  • .env
  • .claude/settings.json
  • .claude/settings.local.json

Port Allocation

Workbloom automatically allocates unique ports for each worktree based on the branch name:

  • Frontend: 5173 + hash
  • Backend: 8080 + hash
  • Database: 5432 + hash

The same branch name will always get the same ports. These port allocations are automatically written to the .env file:

FRONTEND_PORT=6174
BACKEND_PORT=9081
DATABASE_PORT=6433

Development

# Run tests
cargo test

# Build debug version
cargo build

# Build release version
cargo build --release

# Run with debug output
RUST_LOG=debug cargo run -- setup test-branch

License

MIT