← ClaudeAtlas

worktree-safetylisted

Enforces Law 4 (Verify Before Reporting) of the 7 Laws of AI Agent Discipline. Pre-dispatch invariant: validate worktree root before any source-writing tool call. Catches missing .git, fallback path-only creation, stale leases, foreign-session ownership, and non-worktree git operations before they corrupt history.
naimkatiman/continuous-improvement · ★ 6 · AI & Automation · score 75
Install: claude install-skill naimkatiman/continuous-improvement
# Worktree Safety Skill A pre-dispatch invariant. Before any tool call that writes source files or runs git, validate that the current working directory is a registered worktree with a healthy `.git`, owned by this session, on the expected branch. ## When to Use - Before every Edit / Write / Bash that touches source code in a multi-worktree session. - Before any `git` command in an auto-loop. - After any pause/resume — CWD may have drifted, the worktree may have been pruned, the lease may have expired. - When the verification ladder reports a class-`worktree` failure (see `recovery-classification`). ## Why This Skill Exists GSD-2's [CONTEXT.md](https://github.com/gsd-build/gsd-2/blob/main/CONTEXT.md) names "Worktree Safety" as one of four runtime invariant modules. Common failure modes it catches: - **Units dispatch into ghost / invalid worktree roots** — `.git` missing, fallback path-only creation, the worktree was pruned but the loop kept its handle. - **Health checks unit-specific instead of lifecycle-wide** — earlier units (sketch, plan) write into invalid roots before any check runs. - **Brittle exit / merge signals** — relying on artifact presence instead of authoritative branch and commit state. - **Parallel actors mutating the working tree of a worktree they don't own** — a known hazard on this host (see `feedback_parallel_actor.md`). The continuous-improvement repo runs on Windows + Git Bash with `autocrlf=true` and a parallel-actor expectation, both of which