← All hooks

Worktree Placement Guard

blocking stable

Enforces canonical git worktree placement per Common.md §U17. Denies 'git worktree add' commands that target ad-hoc paths (../branch/, /tmp/, sibling dirs). Canonical paths: <repo>/.worktrees/<name>/ for single-repo work, ~/.ai/worktrees/<name>/ for cross-repo or persistent worktrees.

ID hook/worktree-guard Version 1.0.0 Author convergent-systems-key
ai hooks run worktree-guard
Event PreToolUse Language python Trigger tool-nameBash Side effects
  • blocks non-canonical worktree creation with path guidance
linuxmacoswindows Logic is cross-platform. Wiring: use 'ai hooks run worktree-guard' in settings.json — the ai binary discovers Python on each OS. Inspects git command strings via Python. Path separators handled by pathlib. Works on all platforms.
gitworktreegovernanceclaude-code
Attribution: convergent-systems-key.