Skip to content

Commit e6cc45a

Browse files
committed
chore(claude.md): warn against parallel-Claude-hostile git operations
Multiple Claude sessions can run concurrently against the same checkout, parallel worktrees, or sibling clones. Document which git ops break that contract (stash, add -A, branch switching, reset --hard non-HEAD) and the safe alternatives (worktrees, surgical add).
1 parent af2f50a commit e6cc45a

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@
77
- Identify users by git credentials; use their actual name, never "the user"
88
- Use "you/your" when speaking directly; use names when referencing contributions
99

10+
## PARALLEL CLAUDE SESSIONS - WORKTREE REQUIRED
11+
12+
**This repo may have multiple Claude sessions running concurrently against the same checkout, against parallel git worktrees, or against sibling clones.** Several common git operations are hostile to that and silently destroy or hijack the other session's work.
13+
14+
- **FORBIDDEN in the primary checkout** (the one another Claude may be editing):
15+
- `git stash` — shared stash store; another session can `pop` yours.
16+
- `git add -A` / `git add .` — sweeps files belonging to other sessions.
17+
- `git checkout <branch>` / `git switch <branch>` — yanks the working tree out from under another session.
18+
- `git reset --hard` against a non-HEAD ref — discards another session's commits.
19+
- **REQUIRED for branch work**: spawn a worktree instead of switching branches in place. Each worktree has its own HEAD, so branch operations inside it are safe.
20+
21+
```bash
22+
# From the primary checkout — does NOT touch the working tree here.
23+
git worktree add -b <task-branch> ../<repo>-<task> main
24+
cd ../<repo>-<task>
25+
# edit, commit, push from here; the primary checkout is untouched.
26+
cd -
27+
git worktree remove ../<repo>-<task>
28+
```
29+
30+
- **REQUIRED for staging**: surgical `git add <specific-file> [<file>…]` with explicit paths. Never `-A` / `.`.
31+
- **If you need a quick WIP save**: commit on a new branch from inside a worktree, not a stash.
32+
33+
The umbrella rule: never run a git command that mutates state belonging to a path other than the file you just edited.
34+
1035
## PRE-ACTION PROTOCOL
1136

1237
**MANDATORY**: Review CLAUDE.md before any action. No exceptions.

0 commit comments

Comments
 (0)