Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

docs: add Xcode DerivedData cleanup recipe (#1423)

Rickey26333bc87bbe
diff --git a/docs/content/tips-patterns.md b/docs/content/tips-patterns.md
index 610aefc0d..630d05f42 100644
--- a/docs/content/tips-patterns.md
+++ b/docs/content/tips-patterns.md
@@ -267,6 +267,26 @@ To create a worktree and immediately attach:
wt switch --create feature -x 'tmux attach -t {{ branch | sanitize }}'
```
+## Xcode DerivedData cleanup
+
+Clean up Xcode's DerivedData when removing a worktree. Each DerivedData directory contains an `info.plist` recording its project path — grep for the worktree path to find and remove the matching build cache:
+
+```toml
+# ~/.config/worktrunk/config.toml
+[post-remove]
+clean-derived = """
+ grep -Fl {{ worktree_path }} \
+ ~/Library/Developer/Xcode/DerivedData/*/info.plist 2>/dev/null \
+ | while read plist; do
+ derived_dir=$(dirname "$plist")
+ rm -rf "$derived_dir"
+ echo "Cleaned DerivedData: $derived_dir"
+ done
+"""
+```
+
+This precisely targets only the DerivedData for the removed worktree, leaving caches for other worktrees and the main repository intact.
+
## Subdomain routing with Caddy
<!-- Hand-tested 2026-03-07 -->
diff --git a/skills/worktrunk/reference/tips-patterns.md b/skills/worktrunk/reference/tips-patterns.md
index 62b726d43..3ea0d2d87 100644
--- a/skills/worktrunk/reference/tips-patterns.md
+++ b/skills/worktrunk/reference/tips-patterns.md
@@ -256,6 +256,26 @@ To create a worktree and immediately attach:
wt switch --create feature -x 'tmux attach -t {{ branch | sanitize }}'
```
+## Xcode DerivedData cleanup
+
+Clean up Xcode's DerivedData when removing a worktree. Each DerivedData directory contains an `info.plist` recording its project path — grep for the worktree path to find and remove the matching build cache:
+
+```toml
+# ~/.config/worktrunk/config.toml
+[post-remove]
+clean-derived = """
+ grep -Fl {{ worktree_path }} \
+ ~/Library/Developer/Xcode/DerivedData/*/info.plist 2>/dev/null \
+ | while read plist; do
+ derived_dir=$(dirname "$plist")
+ rm -rf "$derived_dir"
+ echo "Cleaned DerivedData: $derived_dir"
+ done
+"""
+```
+
+This precisely targets only the DerivedData for the removed worktree, leaving caches for other worktrees and the main repository intact.
+
## Subdomain routing with Caddy
<!-- Hand-tested 2026-03-07 -->