cyberneticlibrary

Create isolated git worktrees safely

sh-worktreecommandsetup L13
cordsjon/20_agentflow
What it does

Create isolated git worktree workspace

Best for

Isolating feature branches with automatic setup and baseline test verification to prevent cross-branch contamination.

Inputs
  • · branch name
  • · feature name
Outputs
  • · git worktree at specified path
  • · dependencies installed
  • · baseline tests passing
Requires
  • · git
  • · npm/cargo/pip/poetry (per project)
Preconditions
  • · git repo initialized
  • · clean working tree
  • · .gitignore configured
Failure modes
  • · .worktrees not ignored → add to .gitignore+commit
  • · Tests fail at baseline → report and ask
  • · Setup timeout → manual install suggested
  • · Branch already exists → error, user picks different name
Trust signals
  • · Directory priority order (existing → CLAUDE.md → ask)
  • · .gitignore verification before creation
  • · Baseline test verification (pass/fail gate)
  • · Auto-detect project setup (npm/cargo/pip/go)