Create a worktree for: $ARGUMENTS
Slug
If $ARGUMENTS is non-empty, treat the first argument as the slug.
If $ARGUMENTS is empty:
- If a plan file exists at
.claude/state/plans/<latest>.mdin the current project, derive slug from its basename (strip date prefix and.mdextension). - Else generate
<topic>-<6char-hex>and report it.
The slug must be lowercase, hyphen-separated, no spaces.
Branch type
Default to feat/<slug>. If the user's request looks like a bug fix, use fix/<slug>. For cleanups, chore/<slug>.
Steps
-
Find the repo root:
git rev-parse --show-toplevel. Refuse if not inside a git repo. -
Compute target dir:
<repo-parent>/<repo-basename>-<slug>. Refuse if it already exists (offer tocdinto the existing one instead). -
Create the worktree on a new branch:
bashgit worktree add "<target>" -b "<branch>" -
cdinto the worktree dir for all subsequent operations. -
If
package-lock.jsonexists, runnpm ci. If onlypackage.jsonexists, runnpm install --no-package-lock, becausenpm cineeds a lockfile. The worktree holds only tracked files, and the push hooks neednode_modules. -
If
git config core.hooksPathis.husky/_, check that.husky/_exists. If it does not, stop and report it: git skips every repo hook without a word, and the pre-push gate blocks the push. -
Report the new working dir and branch name, then continue with the task.
After creation
The worktree is its own working tree, so the session can change files without colliding with the main checkout.
When work is done:
- Open a PR from the worktree's branch as normal.
- After merge, run
/worktree-mergeto clean up the worktree and remove the local branch.


