{"version":"2.1.271","anchor":"worktree-keep-can-skip-recomputing-git-diff-stats-for-hook","canonical_anchor":"worktree-removal-now-says-commits-are-safe-on-the-server-whe","heading":"Hook-based worktree sessions get better changeset tracking and safer cleanup","tier":"notice","area":"Worktrees","url":"https:\/\/changelogs.core-directive.com\/v\/2.1.271\/e\/worktree-keep-can-skip-recomputing-git-diff-stats-for-hook","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.271","markdown":"### Hook-based worktree sessions get better changeset tracking and safer cleanup\n\nHook-based subagent worktrees now track their real path and changeset more reliably and skip unneeded git work\n\n**What**\n\n- When spawning a subagent with `isolation: 'worktree'` on a hook-based worktree, Claude Code now resolves and stores the worktree's real path (`vettedRealPath`) after creation, logging a warning and keeping the worktree around at cleanup time if that resolution fails.\n\n- Worktree creation now computes a `baseChangeset` when no HEAD commit is available for hook-based worktrees, and threads it along with `sessionDir` through the worktree's metadata for later dirty-check comparisons.\n\n- The confirmation message shown before discarding a worktree with uncommitted work can now note that commits made in the worktree are already stored server-side (with a changeset id) and won't be lost by removing it.\n\n- When exiting a worktree with the \"keep\" action, if the session is hook-based and already has a recorded `originalChangeset`, Claude Code now skips re-running the git status\/diff commands used to compute changed files and commits.\n\n**Why**\n\nThese changes make hook-based worktree sessions (used in managed\/cloud setups without a normal git HEAD) track their state more reliably and avoid unnecessary git work or misleading warnings about losing uncommitted changes.\n\n- Area: Worktrees\n- Tier: You'll notice\n- Useful: 2\/5\n- Signal: 1\/5"}