Skip to content

Conversation

@jamesdlevine
Copy link
Contributor

  • initial version of worktree setup script (dev-setup.sh) which can be run interactively or non-interactively
    • create worktree
    • create conda environment by same name
    • set default PDD_PATH variable in conda environment and also in .env file
    • add .gitignore rule for .env file
    • create symbolic links for prompts/ and data/
  • Makefile will conda environment PDD_CONDA_ENV if set, else to current directory name (worktree name) if parent directory is "worktrees", or else default to "pdd"

Not (yet) present:

  • worktree teardown when done
  • handling of Vertex credentials in setup

jamesdlevine and others added 3 commits January 22, 2026 14:03
- Add PDD_CONDA_ENV variable (defaults to pdd-dev)
- Allow override via environment variable
- Update CONTRIBUTING.md with new default and usage examples

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add scripts/dev-setup.sh for interactive developer environment setup:
  - Optional git worktree creation from main branch
  - Conda environment creation with Python 3.12
  - Symbolic links for prompts/ and data/
  - .env file with PDD_PATH and gitignore rule
  - PDD_PATH set in conda environment config
  - pip install -e '.[dev]' for development dependencies
  - Worktrees always created under PROJECT_ROOT/.pdd/worktrees

- Update Makefile:
  - PDD_CONDA_ENV auto-detects worktrees directory (uses dir name if under
    worktrees/, else defaults to 'pdd')
  - Add PDD_PYTHON_VERSION variable (3.12)
  - Add 'make dev-setup' target to run setup script
  - Add 'make create-conda-env' target for quick conda env creation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use explicit ifndef/endif block to make the precedence clear:
1. PDD_CONDA_ENV from environment (highest priority)
2. Current directory name if under worktrees/
3. "pdd" (default)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gltanaka
Copy link
Contributor

Thanks for tackling this — the worktree setup friction is real and I appreciate you taking a crack at it.

The Makefile parameterization (PDD_CONDA_ENV) is the key insight here and I think that's worth keeping. For the setup script though, I wonder if we could consolidate everything into a single Makefile target instead:

.PHONY: worktree
worktree:
ifndef NAME
	$(error Usage: make worktree NAME=branch-name)
endif
	git fetch origin main
	git worktree add -b $(NAME) ../$(NAME) origin/main
	conda create -n $(NAME) python=$(PDD_PYTHON_VERSION) -y
	@[ -f .env ] && cp .env ../$(NAME)/.env || true
	cd ../$(NAME) && conda run -n $(NAME) --no-capture-output pip install -e '.[dev]'
	@echo ""
	@echo "Done. Run:"
	@echo "  cd ../$(NAME)"
	@echo "  conda activate $(NAME)"
	@echo "  export PDD_CONDA_ENV=$(NAME)"

This gives us the same workflow (make worktree NAME=fix-123) but also handles the credentials gap (copies .env from the main checkout), uses the conventional sibling location for worktrees, and keeps everything discoverable via make help.

What do you think about slimming it down to: (1) the PDD_CONDA_ENV ?= pdd variable + find-replace in Makefile, and (2) this worktree target? That'd cover the use case without the maintenance cost of the separate bash script.

@gltanaka gltanaka requested a review from Copilot January 24, 2026 20:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces developer setup automation to streamline worktree-based development workflows. The main additions are a comprehensive shell script for interactive/non-interactive environment setup and updates to the Makefile to automatically detect and use the appropriate conda environment based on the working directory structure.

Changes:

  • Added scripts/dev-setup.sh for automated worktree and conda environment creation
  • Enhanced Makefile with dynamic conda environment detection
  • Updated CONTRIBUTING.md with clearer conda environment configuration instructions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
scripts/dev-setup.sh New automated setup script that handles worktree creation, conda environment setup, symlinks, and .env file configuration
Makefile Added PDD_CONDA_ENV variable detection logic and replaced hardcoded "pdd" environment references throughout
CONTRIBUTING.md Enhanced documentation for conda environment setup with multiple configuration methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fi

# Create the environment
conda create -n "$ENV_NAME" python="$PYTHON_VERSION" -y
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python version is hardcoded as '3.12' in the default variable. This inconsistency between the variable name 'PYTHON_VERSION' and the actual default value should be aligned with the version mentioned in line 8 of the script comments and line 17 of the Makefile (PDD_PYTHON_VERSION := 3.12).

Copilot uses AI. Check for mistakes.
info "Creating git worktree '$WORKTREE_NAME'..."

# Worktrees are always created under the main project root
WORKTREES_DIR="$PROJECT_ROOT/.pdd/worktrees"
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The worktree directory path '.pdd/worktrees' is hardcoded here but this same path structure is assumed in the Makefile logic (line 10: 'ifeq ($(_PARENT_DIR),worktrees)'). Consider extracting this to a shared constant or documenting the convention to prevent future inconsistencies.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +89
@echo "Creating conda environment '$(_CURRENT_DIR)' with Python $(PDD_PYTHON_VERSION)"
@conda create -n $(_CURRENT_DIR) python=$(PDD_PYTHON_VERSION) -y
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The create-conda-env target uses _CURRENT_DIR directly instead of PDD_CONDA_ENV. This creates an inconsistency where this target bypasses the environment name logic defined at lines 9-15. Consider using $(PDD_CONDA_ENV) for consistency.

Suggested change
@echo "Creating conda environment '$(_CURRENT_DIR)' with Python $(PDD_PYTHON_VERSION)"
@conda create -n $(_CURRENT_DIR) python=$(PDD_PYTHON_VERSION) -y
@echo "Creating conda environment '$(PDD_CONDA_ENV)' with Python $(PDD_PYTHON_VERSION)"
@conda create -n $(PDD_CONDA_ENV) python=$(PDD_PYTHON_VERSION) -y

Copilot uses AI. Check for mistakes.
cd "$REPO_ROOT"

# Run pip install in the conda environment
conda run -n "$ENV_NAME" --no-capture-output pip install -e '.[dev]'
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the conda environment doesn't exist or hasn't been created yet, this command will fail with a potentially unclear error. Consider adding error handling or a check to verify the environment exists before attempting installation.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants