safe-worktreelisted
Install: claude install-skill JohnJackHouzi/safe-worktree
# Safe worktree
Two agents in one directory share one HEAD. When the second one switches branch,
the first one's next commit lands somewhere it was never meant to go, on top of
files it never read. Nothing errors. The work is simply gone from where it should
have been.
This skill makes parallel work safe: a real isolated checkout, a guard that runs
before you commit, and a cleanup that knows a squash merge when it sees one.
## The four rules
1. **One session, one working directory.** Never switch branch in a directory
another session may be using. Create a worktree instead.
2. **Look before you commit.** Re-read `git status` and `git log` immediately
before staging. The repository may have moved since you last looked.
3. **Never rewrite shared history.** No `reset --hard`, no `push --force`, no
`checkout` of a file another session may be editing - config files under
`.claude/` especially.
4. **Never trust `git branch --no-merged`.** It reports a squash-merged branch as
unmerged. Deleting on that signal alone loses nothing; *keeping* on it wastes
hours. Compare content, not ancestry.
## Starting work
```bash
scripts/worktree_new.sh feature/pricing
```
Creates `../<repo>-pricing` as a sibling directory on the same filesystem, checks
out a new branch there, and makes it actually runnable: `node_modules` is
copy-on-write cloned rather than reinstalled, and ignored env files are carried
over. It refuses to place a worktree in `/tmp`, and it refuses a branc