task-observer: new-session updates from 2026-05-01#6
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f587b386c
ℹ️ 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".
| 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). |
There was a problem hiding this comment.
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 👍 / 👎.
| 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). |
There was a problem hiding this comment.
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 👍 / 👎.
Target\nskill: .agents/skills/new-session/SKILL.md\n\n## Observations addressed\n- Observation 12 (journology/log.md): Worktree recovery should minimise workspace sprawl — a clean existing worktree is the safest landing zone after checkpointing accidental main-checkout work → changed: expanded step 1 to check
git worktree listfor a clean existing worktree before creating a new one; only create when no suitable one existsGenerated by Claude Code