Fold Claude Code worktree sessions into their parent project#154
Open
poppinpixels wants to merge 1 commit into
Open
Fold Claude Code worktree sessions into their parent project#154poppinpixels wants to merge 1 commit into
poppinpixels wants to merge 1 commit into
Conversation
Claude Code's per-session worktrees live at <project>/.claude/worktrees/<generated-name>/, so each worktree session showed up as its own project (e.g. "worktrees/zen-joliot-603975") in cost-by-project views, splitting a project's real usage across many ephemeral rows. - project_name_from_cwd now folds any .claude/worktrees path back to the parent project before taking the last two components (POSIX + Windows). - One-time backfill renames existing worktree sessions using the cwd already stored on their turns — no transcript re-read, turns untouched, token totals cannot drift. Gated by schema_meta 'worktree_fold_done', mirroring the topic backfill. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude Code creates per-session git worktrees under
<project>/.claude/worktrees/<generated-name>/(on by default in the desktop app). Becauseproject_name_from_cwdtakes the last two path components, every worktree session becomes its own "project" — my dashboard had 15+ rows likeworktrees/elastic-cori-f29409splitting the real projects' costs.Changes
project_name_from_cwdfolds any.claude/worktreespath back to the parent project (POSIX + Windows paths).cwdalready stored onturns— no transcript re-read,turnsuntouched, so token totals cannot drift. Gated byschema_metaworktree_fold_done, mirroring the topic backfill in Add session topic to Recent Sessions table #147.Not included
A CHANGELOG entry, since the version-parity test ties the top heading to
scanner.VERSION. Suggested bullet for the nextTBDsection, under Scanner:Happy to add an opt-out flag if you'd rather keep per-worktree visibility available.
🤖 Generated with Claude Code