From e1a8f027cd1d5b0e27be897899a5c9055e56100c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 29 May 2026 23:06:45 +0000 Subject: [PATCH] feat(new-session): check for reusable worktree before creating a new one Before creating a new worktree, inspect existing ones for a clean candidate. If a clean worktree exists with no branch-only commits, prefer fast-forwarding it to the target branch over adding sprawl. --- .agents/skills/new-session/SKILL.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.agents/skills/new-session/SKILL.md b/.agents/skills/new-session/SKILL.md index 47c21d9..45243d5 100644 --- a/.agents/skills/new-session/SKILL.md +++ b/.agents/skills/new-session/SKILL.md @@ -16,7 +16,13 @@ Set up a worktree with everything needed to run the dev server: env files, `node ``` If the path is inside `.claude/worktrees/`, you're in a worktree (created externally, e.g. by Claude Code desktop). Skip to step 3. - If you're in the main repo, use the `EnterWorktree` tool to create one. Let it generate a name, or use one the user provides. + If you're in the main repo, **first inspect existing worktrees** before creating a new one: + ```bash + git worktree list + ``` + If a clean worktree with no branch-only commits exists and could serve as the target, prefer reusing it (fast-forward its branch to the target and update `launch.json`) over adding new workspace sprawl. + + Only if no suitable worktree exists: use the `EnterWorktree` tool to create one. Let it generate a name, or use one the user provides. 2. **Identify the worktree directory** (it should now be your CWD).