Skip to content

Commit 9071fca

Browse files
abrichrclaude
andauthored
docs: add worktree safety rule to CLAUDE.md (#94)
Adds a MANDATORY section warning against removing worktrees that other sessions may be using. Removing a worktree kills any Claude session using it as its working directory, with no recovery possible. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4ab4a2a commit 9071fca

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@
1212

1313
This is a hard rule with NO exceptions, even for "small" changes.
1414

15+
## MANDATORY: Never Remove Worktrees You Didn't Create
16+
17+
**NEVER run `git worktree remove` or `git worktree prune` without confirming no other sessions are using them.**
18+
19+
Removing a worktree that another Claude session is using as its working directory **kills that session permanently** — every command fails with "Working directory no longer exists" and the session cannot recover. Uncommitted work is lost.
20+
21+
Before removing ANY worktree:
22+
1. **Ask the user** if other agents/sessions are running
23+
2. Only remove worktrees **you created in this session**
24+
3. Never batch-remove worktrees — each one could be another session's home
25+
26+
This rule also applies to `git clean`, `rm -rf` on worktree paths, and any operation that deletes directories under `.claude/worktrees/`.
27+
1528
### PR Titles MUST Use Conventional Commit Format
1629

1730
PR titles become the squash merge commit message on main. `python-semantic-release` parses these to decide version bumps. **If the PR title doesn't follow the format, no release is created.**

0 commit comments

Comments
 (0)