Lifecycle Hooks (.wt)¶
Run repository-local commands when creating or removing worktrees.
Use this page when: you want repeatable project bootstrap and cleanup per worktree.
.wt Example¶
init_commands:
- link_topsymlinks
- cp $MAIN_WORKTREE_PATH/.env $WORKTREE_PATH/.env
- npm install
- code .
terminate_commands:
- echo "Cleaning up $WORKTREE_NAME"
Available Environment Variables¶
WORKTREE_BRANCHMAIN_WORKTREE_PATHWORKTREE_PATHWORKTREE_NAME
Trust on First Use (TOFU)¶
Because .wt executes arbitrary commands, lazyworktree checks trust state.
Trust modes:
tofu(default): prompt on first encounter or content changenever: do not run.wtcommandsalways: run without prompt
Trust hashes are stored in:
~/.local/share/lazyworktree/trusted.json
Built-in Special Command¶
link_topsymlinks: symlinks untracked/ignored root files and common editor config directories, createstmp/, and runsdirenv allowwhen.envrcexists.