Sprout: CLI tool to automate Git worktree and Docker Compose workflows

4 hours ago 2

A CLI tool to automate git worktree and Docker Compose development workflows.

  • 🌱 Create isolated development environments using git worktrees
  • 🔧 Automatic .env file generation from templates
  • 🚢 Smart port allocation to avoid conflicts
  • 📁 Centralized worktree management in .sprout/ directory
  • 🎨 Beautiful CLI interface with colors and tables

For development:

# Clone the repository git clone https://github.com/SecDev-Lab/sprout.git cd sprout # Install in development mode pip install -e ".[dev]"
  1. Create a .env.example template in your project root:
# API Configuration API_KEY={{ API_KEY }} API_PORT={{ auto_port() }} # Database Configuration DB_HOST=localhost DB_PORT={{ auto_port() }} # Example: Docker Compose variables (preserved as-is) # sprout will NOT process ${...} syntax - it's passed through unchanged # DB_NAME=${DB_NAME}
  1. Create a new development environment:
sprout create feature-branch
  1. Navigate to your new environment:
cd $(sprout path feature-branch)
  1. Start your services:

sprout create <branch-name>

Create a new development environment with automated setup.

List all managed development environments with their status.

Remove a development environment (with confirmation prompts).

sprout path <branch-name>

Get the filesystem path of a development environment.

Show the version of sprout.

sprout supports two types of placeholders in .env.example:

  1. Variable Placeholders: {{ VARIABLE_NAME }}

    • First: Checks if the variable exists in your environment (e.g., export API_KEY=xxx)
    • Then: If not found in environment, prompts for user input
    • Example: {{ API_KEY }} will use $API_KEY if set, otherwise asks you to enter it
  2. Auto Port Assignment: {{ auto_port() }}

    • Automatically assigns available ports
    • Avoids conflicts with other sprout environments
    • Checks system port availability
  3. Docker Compose Syntax (Preserved): ${VARIABLE}

    • NOT processed by sprout - passed through as-is
    • Useful for Docker Compose variable substitution
    • Example: ${DB_NAME:-default} remains unchanged in generated .env

Environment Variable Resolution Example

# Set environment variable export API_KEY="my-secret-key" # Create sprout environment - API_KEY will be automatically used sprout create feature-branch # → API_KEY in .env will be set to "my-secret-key" without prompting # For unset variables, sprout will prompt sprout create another-branch # → Enter a value for 'DATABASE_URL': [user input required]
# Install development dependencies make setup
# Run tests make test # Run tests with coverage make test-cov
# Run linter make lint # Format code make format # Run type checking make typecheck
  • Python 3.11+
  • Git
  • Docker Compose (optional, for Docker-based workflows)

See LICENSE file.

Read Entire Article