From b7f02aca2040b670d0994b495daab245b3cb1cef Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sun, 1 Nov 2026 18:35:29 -0800 Subject: [PATCH] chore: share one pre-commit body with cloud and marketing The hook ran the guard as a bare `sh` line, which stopped a refused commit only because Husky 9 runs hooks with `sh -e`. As a raw git hook the same lines carried on into lint-staged, whose passing exit let the refused commit through. `|| exit 1` stops it without depending on the runner, and a missing-file check says what to run instead of a bare `sh` error. This is the body taskless/taskless#426 and taskless/marketing#88 use, so all three repos run the same hook; the skill documents it. --- .agents/skills/worktrees-pnpm/SKILL.md | 17 ++++++++++++++--- .husky/pre-commit | 9 +++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.agents/skills/worktrees-pnpm/SKILL.md b/.agents/skills/worktrees-pnpm/SKILL.md index 6a4e0308..946be392 100644 --- a/.agents/skills/worktrees-pnpm/SKILL.md +++ b/.agents/skills/worktrees-pnpm/SKILL.md @@ -153,13 +153,24 @@ refused too. It skips when `GITHUB_ACTIONS=true`, because a runner commits from (version PRs, review bots), and a plain clone is a primary checkout. It keys on the variable the runner sets itself rather than `CI`, which any shell can export as an unnamed bypass. A repo on another CI system adds that system's own marker. With Husky, run it first in -`.husky/pre-commit`: +`.husky/pre-commit`. This is the body taskless/cli, taskless/taskless and taskless/marketing +share: ```sh -sh .agents/skills/worktrees-pnpm/scripts/refuse-main-checkout.sh -npx lint-staged +guard=.agents/skills/worktrees-pnpm/scripts/refuse-main-checkout.sh +if [ ! -f "$guard" ]; then + echo "pre-commit: $guard is missing. Run pnpm install (or pnpm dotagents install) first." >&2 + exit 1 +fi +sh "$guard" || exit 1 +pnpm exec lint-staged ``` +The `|| exit 1` is load-bearing outside Husky. Husky 9 runs a hook as `sh -e`, so a bare +`sh "$guard"` line happens to stop there, but the same two lines as a raw git hook carry on into +`lint-staged`, and its passing exit lets the refused commit through. The missing-file check +turns a bare `sh` error into one that says what to run. + Without Husky, call it from `.git/hooks/pre-commit`, or from whatever hook manager the repo uses. A person who really means to commit in the primary checkout runs `git commit --no-verify`. An agent never gets past it, whether by passing `--no-verify`, setting `GITHUB_ACTIONS`, or any diff --git a/.husky/pre-commit b/.husky/pre-commit index fac8e60d..9782c724 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,7 @@ -sh .agents/skills/worktrees-pnpm/scripts/refuse-main-checkout.sh -npx lint-staged +guard=.agents/skills/worktrees-pnpm/scripts/refuse-main-checkout.sh +if [ ! -f "$guard" ]; then + echo "pre-commit: $guard is missing. Run pnpm install (or pnpm dotagents install) first." >&2 + exit 1 +fi +sh "$guard" || exit 1 +pnpm exec lint-staged