Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/new-session/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exclude main checkout from reusable worktree candidates

This new reuse rule can accidentally select the main checkout as the “clean existing worktree” (especially when the target branch is main), because git worktree list includes the main repo entry as well; step 2 in this same file even relies on that [main] entry. If that happens, the rest of the flow runs in the main repo instead of an isolated worktree, which can lead to accidental main-branch edits/commits and incorrect worktree port-lock setup. Add an explicit guard that reusable candidates must be linked worktrees (e.g., under .claude/worktrees/) and never the [main] entry.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify cleanliness with git status before reusing a worktree

The instruction says to use git worktree list to find a worktree with “no uncommitted changes,” but that command does not expose dirty/clean state (git worktree list -h only provides --porcelain, --verbose, and --expire output modes). Following this step as written can therefore reuse a worktree that still has local changes from an earlier task, contaminating a new session. Require an explicit per-candidate check such as git -C <path> status --porcelain before reuse.

Useful? React with 👍 / 👎.


2. **Identify the main repo root.**
The main repo is always the entry in `git worktree list` with `[main]`:
Expand Down