Shell utilities for creating workspaces (git worktrees) with optional Python virtual environments using uv.
Create isolated workspaces for parallel development. Each workspace gets its own branch. Python projects (detected via pyproject.toml) automatically get an activated virtual environment. Uses uv sync for fast, reproducible environment setup.
- bash or zsh
- git
- uv - install with
brew install uv pyproject.tomlin Python projects (norequirements.txtsupport)
mkdir -p ~/.local/bin
cp venv-functions.sh workspace-functions.sh ~/.local/bin/
chmod +x ~/.local/bin/venv-functions.shAdd to ~/.zshrc or ~/.bashrc:
source ~/.local/bin/workspace-functions.shReload your shell:
source ~/.zshrc # or ~/.bashrcFrom any git repository:
workspace # From HEAD
workspace main # From main branch
workspace main --python # Force Python venv setup
workspace main --python-version 3.12 # Specify Python versionThis creates:
- Workspace at
~/.workspaces/<repo>/<name> - Branch with the same name (Docker-style random name like
eager-turing) - Activated virtual environment (if Python project detected or
--pythonflag used)
A Python venv is automatically created when:
--pythonor--pyflag is passed, ORpyproject.tomlexists in the project root
venv-setup # Python 3.14
venv-setup 3.12 # Specify versionworkspace listworkspace remove <name>Removes the workspace directory and deletes the branch.
workspace helpWorkspaces are stored at ~/.workspaces/<repo>/<name>.
Default Python version is 3.14. Override per-command with --python-version or modify DEFAULT_PYTHON_VERSION in venv-functions.sh.
venv-functions.sh uses uv sync and automatically:
- Creates
.venvdirectory with all dependencies - Creates/updates
uv.lockfor reproducible builds - Pins Python version in
.python-versionfile - Installs dev dependencies from
[dependency-groups] - Offers to install missing Python versions via
uv python install - Adds
.venvto.gitignoreif missing - Creates
.vscode/settings.jsonfor Python interpreter
When setting up a Python environment, uv.lock is automatically created. This file:
- Ensures reproducible builds across machines and workspaces
- Should be committed to git
- Is automatically kept in sync by
uv sync
Claude Code works seamlessly with uv-managed projects. Use uv run to execute commands without activating the virtual environment:
uv run python script.py # Run Python scripts
uv run pytest # Run tests
uv run ruff check . # Run lintersThis is the recommended approach for tooling and CI/CD pipelines.
Run venv-functions.sh directly in any directory with pyproject.toml:
~/.local/bin/venv-functions.sh # Python 3.14
~/.local/bin/venv-functions.sh --python-version 3.12 # Specify version
~/.local/bin/venv-functions.sh --non-interactive # Auto-install Python if needed
~/.local/bin/venv-functions.sh --force-non-git # Skip git checkUse --non-interactive when calling from scripts or automation:
- Syncs project dependencies (idempotent)
- Auto-installs missing Python version
- Creates/updates
uv.lock
MIT