# Support "delete-worktree" key in worktrees.json

**URL:** <https://forum.cursor.com/t/support-delete-worktree-key-in-worktrees-json/139624>\
**Category:** Feature Requests\
**Created:** [October 29, 2025, 11:53pm UTC](https://forum.cursor.com/t/support-delete-worktree-key-in-worktrees-json/139624 "2025-10-29T23:53:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blimmer](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/blimmer/32/84842_2.png) [@blimmer](https://forum.cursor.com/u/blimmer)\
**Post date:** [October 29, 2025, 11:53pm UTC](https://forum.cursor.com/t/support-delete-worktree-key-in-worktrees-json/139624/1 "2025-10-29T23:53:03Z")

</div>

### Feature request for product/service

Cursor IDE

### Describe the request

**Problem:**  
The existing setup-worktree hook allows running scripts when a worktree is created, but there’s no corresponding cleanup hook when worktrees are deleted. This leads to orphaned resources (e.g., Docker containers) that were created during worktree initialization.

**Use Case:**  
When using `setup-worktree` to start worktree-specific Docker Compose services, these containers persist after the worktree is cleaned up, resulting in resource leaks and cluttered environments.

**Proposed Solution:**  
Add `delete-worktree`, `delete-worktree-unix`, and `delete-worktree-windows` hooks that:

- Run automatically when a worktree is deleted/cleaned up
- Follow the same pattern and behavior as the existing setup-worktree hooks
- Execute before the worktree directory is removed

Example Usage:

```auto
{
  "setup-worktree-unix": "./scripts/start-worktree-services.sh",
  "delete-worktree-unix": "./scripts/cleanup-worktree-services.sh"
}

```

This would enable proper cleanup of worktree-specific resources, mirroring the initialization capabilities already provided.

---

<div class="post-metadata">

**Author:** ![Benjamin\_Grosse](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@Benjamin\_Grosse](https://forum.cursor.com/u/Benjamin_Grosse)\
**Post date:** [February 20, 2026, 9:18pm UTC](https://forum.cursor.com/t/support-delete-worktree-key-in-worktrees-json/139624/2 "2026-02-20T21:18:30Z")

</div>

I very much want this as well!

---

<div class="post-metadata">

**Author:** ![Jason\_Garber](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/jason_garber/32/104029_2.png) [@Jason\_Garber](https://forum.cursor.com/u/Jason_Garber)\
**Post date:** [April 3, 2026, 8:40pm UTC](https://forum.cursor.com/t/support-delete-worktree-key-in-worktrees-json/139624/3 "2026-04-03T20:40:05Z")

</div>

I came here looking for this feature as well! 🙏
