[FEATURE] add auto generated name marker flag for json input to worktree hooks
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
One use case of worktree hooks, in addition to the obvious case of supporting different VCS, is to enable power users to exercise a high degree of control over claude code's behaviour when creating and tearing down a worktree. It may be desirable in some cases to provided customized behaviour based on the worktree name, and in particular branching behaviour when using a user-provided value vs the auto generated stock value. Right now there is no deterministic way to distinguish these two cases.
Proposed Solution
My proposal is simple. Just add a single field to the input JSON given to the hook isRandomName that is true if Claude Code is using a randomly generated worktree name (i.e. empty -w flag) and false if the user provded a name via an argument to the -w flag.
Alternative Solutions
Matching on the name is the only obvious solution but this is not robust.
Priority
Medium - Would be very helpful
Feature Category
Configuration and settings
Use Case Example
I want to have my worktree creation hook intelligently prepend a prefix to a default worktree branch name when the user did not provide a name and use this prefix as a marker in my later worktree removal hook to decide what to do with the branch on that worktree.
Additional Context
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗