← ClaudeAtlas

safe-worktreelisted

Run several agents or sessions on one repository without stealing each other's work. Use before starting feature work, before any commit or push when other sessions may be open, and when a dev server has to run from a second copy of the repo. Triggers on "work on this in parallel", "another session", "start a branch", "set up a worktree", "before I commit", "did someone else change this", "the branch changed", "clean up this branch".
JohnJackHouzi/safe-worktree · ★ 0 · AI & Automation · score 72
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