From: Kristoffer Haugsbakk Date: Mon, 07 Sep 2026 18:18:47 GMT Subject: Re: [PATCH v2 0/4] worktree: add lifecycle hooks Message-ID: In-Reply-To: On Mon, Sep 7, 2026, at 16:30, Domen Kožar wrote: > A gentle ping on the single "post-worktree" hook proposal below. > > As coding agents increasingly create and discard worktrees, reliable > lifecycle notifications matter more because tools managing environments > and cleanup cannot control every caller invoking Git. > > Would this interface address your concerns? I'm happy to prepare v3 if > we can agree on the direction. The problem is multiple callers invoking Git with different intentions. What if `git worktree add` learned an option `--id=` which is then stored in the worktree? This would communicate that whoever calls git-worktree(1) commands with this ID is the one who owns it.[1] git-worktree(1) commands which do not get an `--id` (and specifically that ID) does nothing to owned worktrees. [1]: You know, among friendly and cooperating processes. Then you don’t need hooks for adding, removing, pruning and whatever else. I could imagine an agent tool that uses it’s own ID to manage a pool of worktrees. I could imagine more metadata, like recording a timestamp for worktree expiry... but you don’t need anything more in git-worktree(1) itself if you have this ID concept. Then you can let tools implement it themselves. They won’t have their worktrees bothered/clobbered by other tools, so they can manage the whole lifecycle in peace.