What
Custom hooks for creating and removing worktrees, enabling worktree isolation to work with any version control system—not just Git.
Usage
Configure hooks in your settings.json:
{
"hooks": {
"WorktreeCreate": [{
"command": "your-worktree-create-script"
}],
"WorktreeRemove": [{
"command": "your-worktree-remove-script"
}]
}
}Details
WorktreeCreatehook receives JSON input withname(suggested worktree slug); stdout should contain the absolute path to the created worktreeWorktreeRemovehook receives JSON input withworktree_path(absolute path to worktree); exit code 0 indicates successful removal- Enables worktree isolation for non-Git VCS systems (Mercurial, SVN, etc.)
- Error messages guide users when hooks are missing or fail
Evidence
Hook types and error messages (search for "WorktreeCreate", "WorktreeRemove", "Configure WorktreeCreate/WorktreeRemove hooks")
Strings lifted out of the shipped bundle, so the claim above can be checked against them.
One source agreesOne thing we can check says the same as this entry.
Anthropic's release notes agree
Added WorktreeCreate and WorktreeRemove hook events, enabling custom VCS setup and teardown when agent worktree isolation creates or removes…