From 95869de97a8e1e19246021d62a5c4e1aa122ff0b Mon Sep 17 00:00:00 2001 From: Anilcan Cakir Date: Thu, 3 Sep 2026 19:28:35 +0300 Subject: [PATCH 1/3] chore(worktree): keep Claude Code worktrees out of the working tree Worktrees used to sit beside the checkout as -, which put them in the workspace directory next to the real repositories and left EnterWorktree unusable, since that tool writes to a fixed .claude/worktrees/. Pattern proven on fluttersdk/magic_starter#124. --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index ee89d7a..2d56632 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,11 @@ app.*.map.json # AI coding tools .ac/ +# Worktrees Claude Code creates for parallel sessions and isolated subagents. +# Only this subdirectory: the rest of `.claude/` is tracked, because the rules +# under it are part of the repository. +.claude/worktrees/ + # Package lock file pubspec.lock From ad284363e1289aa47e7ee13ce102b31c6bf62498 Mon Sep 17 00:00:00 2001 From: Anilcan Cakir Date: Thu, 3 Sep 2026 20:01:20 +0300 Subject: [PATCH 2/3] docs(worktree): record that git clean now reaches a live worktree --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2d56632..5dc917a 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,11 @@ app.*.map.json # Worktrees Claude Code creates for parallel sessions and isolated subagents. # Only this subdirectory: the rest of `.claude/` is tracked, because the rules -# under it are part of the repository. +# under it are part of the repository.# +# They sit inside the working tree rather than beside it, so `git clean -xdf` here +# wipes a live worktree's contents while `.git/worktrees/` survives, leaving a +# registration that needs `git worktree prune`. A worktree's `.git` is a file rather +# than a directory, so git's nested-repo guard does not stop it. .claude/worktrees/ # Package lock file From 7e08b3220bcdbf23c39d41e5d5d8a74e3a097adc Mon Sep 17 00:00:00 2001 From: Anilcan Cakir Date: Thu, 3 Sep 2026 20:31:10 +0300 Subject: [PATCH 3/3] fix(worktree): git clean -xdf skips a worktree, only -xdff does not The comment claimed plain -xdf wipes a live worktree because its .git is a file rather than a directory. Measured on a scratch repo: the dry run prints "Skipping repository .claude/worktrees/slug", the worktree survives -xdf with its untracked files intact, and only -xdff removes it and leaves the registration prunable. The guard keys on the gitlink, not on the form of .git. Also splits the stray # that joined the two comment blocks. --- .gitignore | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5dc917a..84f723e 100644 --- a/.gitignore +++ b/.gitignore @@ -48,11 +48,13 @@ app.*.map.json # Worktrees Claude Code creates for parallel sessions and isolated subagents. # Only this subdirectory: the rest of `.claude/` is tracked, because the rules -# under it are part of the repository.# -# They sit inside the working tree rather than beside it, so `git clean -xdf` here -# wipes a live worktree's contents while `.git/worktrees/` survives, leaving a -# registration that needs `git worktree prune`. A worktree's `.git` is a file rather -# than a directory, so git's nested-repo guard does not stop it. +# under it are part of the repository. +# +# They sit inside the working tree rather than beside it. `git clean -xdf` leaves them +# alone: git's nested-repository guard resolves a gitfile too, so it reports "Skipping +# repository .claude/worktrees/" and the contents survive. `git clean -xdff` does +# not skip them, and wipes a live worktree while `.git/worktrees/` survives, +# leaving a registration that `git worktree prune` then has to clear. .claude/worktrees/ # Package lock file