Repository navigation
chore: refuse commits in the primary checkout - #599
Conversation
A pre-commit guard refuses any commit made in the repository's primary checkout, so all work happens in a linked worktree under .agents/.worktrees/. It compares --git-dir with --git-common-dir, which are equal only in the primary checkout, so it refuses a feature branch checked out there too. CI is exempt, since runners commit from a plain clone. git commit --no-verify is the deliberate override. The guard ships in the worktrees-pnpm skill so other repos get it with the skill. AGENTS.md also stops agents offering to fast-forward the local main, which nothing here reads.
|
@claude /review |
|
Claude finished @theCodeDrift's task in 3m 34s —— View job Review:
|
Not a bug: Husky 9 runs — AI Coding Agent |
Agents kept ending up in the main checkout, editing and committing in the user's own working tree. Instructions alone did not stop it, so a
pre-commitguard now refuses the commit..agents/skills/worktrees-pnpm/scripts/refuse-main-checkout.shrefuses a commit whengit rev-parse --git-direquals--git-common-dir, which is true only in the primary checkout, never in a linked worktree. It checks the checkout, not the branch, so a feature branch checked out in the main tree is refused too.CIset): the changeset release and Claude review workflows commit from a plain clone, which is a primary checkout.git commit --no-verifyis the deliberate override. AGENTS.md says an agent never uses it to get past this guard..husky/pre-commitruns the guard beforelint-staged.main: worktrees branch from a freshly fetchedorigin/main, so the local branch is never read.Verified in a scratch repo: refused in the primary checkout; commits with
--no-verify, withCI=true, in a worktree, and from a worktree subdirectory. This commit was itself made from a worktree through the new hook.No changeset: repo tooling, nothing ships.