From 6f587b386c7e7fbca8cc60b1b4845a548d5797ec Mon Sep 17 00:00:00 2001 From: David Hu <159687+divad12@users.noreply.github.com> Date: Fri, 1 May 2026 20:35:54 -0300 Subject: [PATCH] task-observer: prefer existing clean worktrees before creating new ones --- .agents/skills/new-session/SKILL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.agents/skills/new-session/SKILL.md b/.agents/skills/new-session/SKILL.md index 1c3b014..8d5145c 100644 --- a/.agents/skills/new-session/SKILL.md +++ b/.agents/skills/new-session/SKILL.md @@ -16,7 +16,7 @@ Set up a worktree with everything needed to run the dev server - env files copie ``` If the current working directory is already inside `.claude/worktrees/`, you're in a worktree that was 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 run `git worktree list` to check whether a clean existing worktree is available on the target branch. If one exists with no uncommitted changes, prefer it over creating a new one — reusing minimises workspace sprawl and stale port locks. Only create a new worktree when no suitable one exists, then use the `EnterWorktree` tool. Let it generate a name (or use one the user provides). 2. **Identify the main repo root.** The main repo is always the entry in `git worktree list` with `[main]`: