Conveniences for setting up worktrees#387
Conveniences for setting up worktrees#387jamesdlevine wants to merge 3 commits intopromptdriven:mainfrom
Conversation
- 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>
|
Thanks for tackling this — the worktree setup friction is real and I appreciate you taking a crack at it. The Makefile parameterization ( .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 ( What do you think about slimming it down to: (1) the |
There was a problem hiding this comment.
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.shfor 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 |
There was a problem hiding this comment.
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).
| info "Creating git worktree '$WORKTREE_NAME'..." | ||
|
|
||
| # Worktrees are always created under the main project root | ||
| WORKTREES_DIR="$PROJECT_ROOT/.pdd/worktrees" |
There was a problem hiding this comment.
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.
| @echo "Creating conda environment '$(_CURRENT_DIR)' with Python $(PDD_PYTHON_VERSION)" | ||
| @conda create -n $(_CURRENT_DIR) python=$(PDD_PYTHON_VERSION) -y |
There was a problem hiding this comment.
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.
| @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 |
| cd "$REPO_ROOT" | ||
|
|
||
| # Run pip install in the conda environment | ||
| conda run -n "$ENV_NAME" --no-capture-output pip install -e '.[dev]' |
There was a problem hiding this comment.
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.
Not (yet) present: