task-observer: new-session updates from 2026-06-12#51
Conversation
… new one Adds a step to inspect existing worktrees for a clean reusable candidate before invoking EnterWorktree. Prevents workspace sprawl when accidental main-checkout work can be resolved by fast-forwarding an existing clean worktree rather than creating another.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a71b7b2920
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| git worktree list --porcelain | ||
| ``` | ||
|
|
||
| For each listed worktree, check if it is clean (`git -C <path> status --short` returns nothing) and has no branch-only commits (`git -C <path> log <target>..HEAD` is empty). If a suitable clean worktree exists, fast-forward it to the target branch and use it — reusing an existing worktree avoids workspace sprawl. Only if no suitable clean worktree exists, use the `EnterWorktree` tool to create one. Let it generate a name, or use one the user provides. |
There was a problem hiding this comment.
Exclude the main worktree from reuse candidates
When this runs from the main repo, git worktree list --porcelain includes the main worktree as the first listed worktree (I checked the command output in this repo). Because the main repo can be clean and have no <target>..HEAD commits, this instruction can select the main repo as the “suitable clean worktree”; then step 3 runs setup.sh, which explicitly exits when WORKTREE equals MAIN_REPO. Please tell agents to skip the current/main worktree before evaluating reusable candidates.
Useful? React with 👍 / 👎.
Target
skill:
.agents/skills/new-session/SKILL.mdObservations addressed
git worktree list, check clean status and no branch-only commits) before invoking EnterWorktreeGenerated by Claude Code