Sometimes. Current Claude Code documentation says it automatically removes a clean Git worktree when you exit an unnamed interactive session, if Claude Code created that worktree. Named sessions prompt first, and work that is not clean—or whose state Claude cannot verify—also prompts. Git documents git worktree lock as protection against pruning and ordinary Git removal, but Claude Code does not expressly say that a user-set lock prevents every interactive exit-cleanup path. If the worktree matters, choose Keep when offered and do not rely on the lock alone without confirming behavior in your installed version.
When does Claude Code remove a worktree on exit?
The rule applies to a specific case: a Git worktree Claude Code created, used in an unnamed interactive session, that Claude determines is clean when the session ends. Anthropic’s worktree documentation says Claude removes that worktree and its branch automatically in this case.
As an Amazon Associate I earn from qualifying purchases.
Other session or worktree states follow different paths:
Recommended Free Tools
| Situation | Documented behavior |
|---|---|
| Unnamed interactive session; Claude-created Git worktree is clean | Claude removes the worktree and branch on exit. |
| Named interactive session | Claude asks whether to keep or remove the worktree. |
| Worktree contains changes, untracked files, uncommitted work in a checked-out submodule, or new commits | Claude prompts to keep or remove it. |
| Claude cannot verify the worktree’s state | Claude prompts rather than automatically removing it. |
Noninteractive -p run |
There is no exit prompt, and Claude does not clean up the worktree at exit. |
These are Claude Code’s documented behaviors, not a blanket rule for every directory that happens to be a Git worktree. In particular, the documented periodic retention sweep excludes worktrees created manually with git worktree add, even if they are later used with --worktree and backgrounded.
#1 Best Overall
- Dell T3620 Music Production Workstation PC / Studio
- Intel i7-6700 4-Core 3.4GHz (4.0GHz Turbo) CPU
- 32GB DDR4 Memory - 512GB SSD (boot) + 2TB HDD (Storage)
- Intel HD Graphics 530 (2x Display Port & HDMI)
- Operating System: Windows 11 Pro
Does git worktree lock stop Claude Code’s interactive cleanup?
Git’s guarantee and Claude Code’s guarantee are not the same thing. The Git worktree manual says a lock prevents a worktree from being automatically pruned and “also prevents it from being moved or deleted.” Git’s ordinary git worktree remove is limited to clean worktrees; its manual documents --force for removing an unclean one.
However, Claude Code’s interactive-exit documentation does not explicitly say that its cleanup decision honors a user-set Git lock. It is reasonable to use a lock for the protection Git documents, but the available documentation does not establish that the lock blocks every Claude Code interactive cleanup path. If you need to preserve work, select Keep at Claude’s prompt when one appears, and verify lock behavior on your installed Claude Code version before treating the lock as your only safeguard.
Rank #2
- [Content Creation Workstation PC] - Powered by the Intel Hexa-Core i7 (8th Gen) processor with 32GB DDR4 RAM and NVIDIA's GeForce K1200 4GB Graphics Card, this Workstation PC Computer is built for creative environments.
- [NVIDIA's GeForce K1200 4GB] Graphic support built to be an efficient workstation for creative applications like photo and video editing, 3D Design, AutoCAD, and much more.
- [Software Compatibility] Workstation PC for use with independent software vendors (ISV) and certified for use with modeling, rendering, and engineering software from Adobe, AutoCAD, 3DS Max, and many more.
- [Massive Storage Solutions] An ultra-fast 500GB PCIe M.2 NVMe setup as the primary boot device; Boot and load programs with little to no lag; ; An additional 1TB Solid State Drive (SSD) is installed for additional storage; Never run out of storage.
- [Connectivity for Creative Projects] - USB 3.0 (x5) | USB 2.0 (x4) | USB Type-C (x1) | DisplayPort (x2) | Serial Port (x1) | Audio Combo Jack (x1) | RJ-45 Ethernet (x1) | Internal SATA (x4)
How to lock a worktree for Git’s documented protection
- From a terminal, lock the worktree by path:
git worktree lock <path> --reason "keep for later". Confirm the accepted option order withgit worktree lock -hif your installed Git version differs. - Check the registered worktrees with
git worktree list --verbose. Git’s verbose listing identifies locked worktrees. - When you deliberately intend to remove the lock, run
git worktree unlock <path>. Unlocking removes that protection; do not do it just to clear a warning if you still need the worktree preserved.
If manual removal is refused because the worktree is locked, unlock it only when cleanup is intentional, then use Git’s removal command. Ordinary removal accepts only a clean worktree; Git documents git worktree remove --force <path> for an unclean worktree, so inspect and preserve any needed files before using force.
What happens to locks in noninteractive and background sessions?
For noninteractive -p runs, Claude documents no exit cleanup. A lock set when the worktree was created can therefore remain until a later stale-lock sweep. For background or subagent retention sweeps, Claude distinguishes locks it created from locks a user set: it releases its own lock after the session process exits, but the sweep does not release a user-set lock.
Rank #3
- 【Processor】Intel Core i7-7700 delivers fast, reliable performance for office work, web browsing, and everyday multitasking.
- 【Storage & Memory】8GB DDR4 RAM for smooth multitasking; 256GB NVMe SSD for quick boot times and plenty of room for files and applications.
- 【WiFi Included】A USB WiFi adapter is included in the box, so you can join a wireless network as soon as you power the machine on — no separate purchase needed. DisplayPort video output, multiple USB 3.0/3.1 ports, RJ-45 Gigabit Ethernet, and audio jacks cover everyday home and office needs.
- 【Ready to Use】Ships with Windows 11 Pro pre-installed and activated, plus a wired keyboard and mouse. Plug in and get to work.
- 【BUY WITH CONFIDENCE】Professionally refurbished, tested, and certified to look and work like new; 90-day warranty and technical support.
Claude’s documentation also notes a version distinction: before Claude Code v2.1.210, locks left by killed sessions remained until someone ran git worktree unlock. Check the behavior documented for the version you use, especially if a background process was terminated unexpectedly.
What if Claude adopted a worktree I created?
Anthropic’s documented automatic exit rule is specifically about Git worktrees Claude Code created. A user report in Claude Code issue #92425 describes ten tests on macOS with Claude Code 2.1.261 on September 5, 2026: an adopted, pre-existing worktree directory disappeared on clean unnamed exit while its branch remained. That report is specific to one person’s version and setup; it is not an official guarantee or broad validation. If you need to preserve an adopted worktree, do not infer safety from who created it—use the Keep choice if offered and verify your version’s behavior.
Rank #4
- [Content Creation Workstation PC] - Powered by the Intel Hexa-Core i5 (8th Gen) processor with 16GB DDR4 RAM and NVIDIA's GeForce K1200 4GB Graphics Card, this Workstation PC Computer is built for creative environments.
- [NVIDIA's GeForce K1200 4GB] Graphic support built to be an efficient workstation for creative applications like photo and video editing, 3D Design, AutoCAD, and much more.
- [Software Compatibility] Workstation PC for use with independent software vendors (ISV) and certified for use with modeling, rendering, and engineering software from Adobe, AutoCAD, 3DS Max, and many more.
- [Massive Storage Solutions] An ultra-fast 120GB PCIe M.2 NVMe setup as the primary boot device; Boot and load programs with little to no lag; ; An additional 500GB Solid State Drive (SSD) is installed for additional storage; Never run out of storage.
- [Connectivity for Creative Projects] - USB 3.0 (x5) | USB 2.0 (x4) | USB Type-C (x1) | DisplayPort (x2) | Serial Port (x1) | Audio Combo Jack (x1) | RJ-45 Ethernet (x1) | Internal SATA (x4)
If you use a custom WorktreeCreate hook, Anthropic directs readers to the corresponding WorktreeRemove hook behavior in its worktree documentation.
Quick Recap
Best Value
- 【Next-Gen Performance 】Powered by the 14th Gen Intel i7-14700 with20cores, 28Threads and up to 5.0 GHz turbo, this desktop handles multitasking, office workloads, and light creative tasks with ease.
- 【High-Speed RAM & Ample Storage】: Configure your system with up to 64GB of DDR5 Memory for ultra-smooth multitasking and performance. Choose up to a 4TB PCIe M.2 SSD for blazing-fast boot times and generous storage capacity to easily handle large files and demanding applications.
- 【Comprehensive Connectivity】: Stay connected with a versatile selection of ports, including SD-Card Reader, 4 USB 3.2 Gen 2, 3 USB 3.2 Gen 3, 1x USB-C, HDMI-in 1.4, HDMI-out 2.1, Display Port, Ethernet (RJ45), and a headphone/microphone combo jack. Wi-Fi 6 and Bluetooth combo ensure fast and reliable wireless connectivity for all your devices.
- 【Ready for business】: Keep your data secure with a hardware TPM security chip. And when you need to step away from your desk, simply secure your desktop using the built-in lock slot or padlock loop.
- 【Miscrosoft Powered Windows 11Pro with Accessories】 : Run the latest applications with Windows 11Pro, offering a user-friendly and efficient experience. The package includes both US English keyboard and mouse, completing your setup with renown attention to quality and style.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




