Repository navigation
chore(git-hooks): install the guardrails git hooks as shared lefthook jobs - #9462
Closed
kyle-sexton wants to merge 2 commits into
Closed
kyle-sexton wants to merge 2 commits into
kyle-sexton wants to merge 2 commits into
Conversation
… jobs Commit the guardrails plugin's commit-msg-convention, pre-commit-content and reference-verify entries under .githooks/guardrails/ (install.mjs copy --scope shared, guardrails 0.55.4) with their lefthook.yml jobs, and record the subject_pattern they enforce in .claude/source-control.md. The check-affected pre-push test copies lefthook.yml into a fixture repo; it now copies .githooks/ too, so the new pre-push job finds its script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ShellCheck flags the relocated .githooks/guardrails/ copies (their source directives point at plugin-tree paths), and the two path-pattern copies self-match the machine-path check, as plugins/guardrails/lib/path-detection/ already does. The sources stay linted under plugins/guardrails/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 23, 2026
Member
Author
|
Superseded by #9504: guardrails git hooks reach repositories through a lefthook remotes entry, so per-repo shared copies are no longer used. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No related issue: rollout of the guardrails git hooks as shared, committed lefthook jobs, following the standards#852 pilot; the installer defects it hits are tracked in #9426.
Summary
Installs the guardrails plugin's three git-hook entries in this repository so every clone gets them from
lefthook install, and records the commit subject pattern they enforce:commit-msg-convention(commit-msg): the subject againstsubject_patternin.claude/source-control.md.pre-commit-content(pre-commit): secrets and machine-specific paths on added lines.reference-verify(pre-push): CLI flags,/plugin:skillreferences and deleted paths on pushed lines.Fix
.githooks/guardrails/: plugin-owned copies written byinstall.mjs copy --scope shared(guardrails 0.55.4, the versionplugins/guardrails/is at on main; each copy matches its source apart from the installer's stamp line), staged100755where they carry a shebang.lefthook.yml: the three jobs from the installer's snippets.guardrails-reference-verifyis appended to the existingpre-pushlist withuse_stdin: true; the existingcheck-affectedjob does not setuse_stdin(it runs with</dev/nulland judges HEAD, as its comment says), so the one stdin lefthook hands out per hook goes to the guardrails job. Newpre-commitandcommit-msgsections; this file had no pre-commit lane, so there is noexcludeto extend..github/workflows/pr-require-checks.yml:.githooks/guardrails/added to the ShellCheck action'sexclude(the relocated copies fail SC2218, SC1091 and others because theirsourcepaths point at plugin-tree locations; the sources stay linted underplugins/guardrails/), and:(exclude).githooks/guardrails/*-path-patterns.shto the machine-path check (the two pattern-lib copies self-match, asplugins/guardrails/lib/path-detection/**already does)..claude/hooks/check-affected-pre-push.test.sh: one line outside the hook files. Its lefthook end-to-end case copieslefthook.ymlinto a fixture repo and pushes through lefthook; without.githooks/in the fixture the new pre-push job exited 127 andlefthook lets the push through when the merge-base checks passfailed (50 pass, 1 fail). It now copies.githooks/too: 51 pass, 0 fail..claude/source-control.md:subject_patternis the twelve Conventional Commits typesci-statusaccepts, an optional scope, plus git's ownMerge ...andRevert "..."subjects; the intro paragraph now names it among the set keys..gitattributesdecision (.githooks/** text eol=lf) is left out:* text=auto eol=lfalready covers it.scripts/sync-shared-copies.sh --check(520 registered copies match) andscripts/check-cross-plugin-source-drift.shpass with the copies present; neither scans.githooks/, so no exclusion was needed there.Verification
Observation runs against this repository's history in report-only mode:
reference-verifyorigin/main~200..origin/main, 236 changed.md/.sh/.ps1files, 2 min 19 s--scheduledinplugins/machine-health/CHANGELOG.mdandplugins/machine-health/skills/setup/SKILL.md)--scheduledis a skill argument inside the quoted prompt ofclaude -p "/machine-health:audit on-demand --scheduled", read as a flag of aclaude on-demandsubcommand. Zero skill-reference and stale-path findings. No payload in the range hit the argument-size limit (noArgument list too longin the replay's stderr)pre-commit-content/home/alice/...line in a staged.mdwas reported, rc 1, so the replay did scancommit-msg-conventionsubject_patterntested against the last 500 subjects on mainAlso:
lefthook validate: All good.actionlinton the workflow: clean.pre-commit-contenttook 70 s over the 10.7k vendored lines; the next commit's took 0.09 s,commit-msg-convention0.02 s.reference-verifyon this branch's push: 16 s.scripts/check-affected.shpasses everything except ShellCheck on the copies: its local ShellCheck mirror does not read the workflow'sexclude:, and the pre-push job runs the merge-base copy, so this branch's pushes skip that one job (LEFTHOOK_EXCLUDE=check-affected) and CI judges ShellCheck with the new exclude. Untilscripts/check-affected.shdrops.githooks/guardrails/*from its shell list, every refresh of the copies hits the same block.scripts/affected-tests.sh --allow-unmappedselects, plusscripts/check-affected-gates.test.sh) in 191 s. 60 pass. 3 fail for this machine's environment only:check-script-contract.test.shneedsnode_modules/.bin/htmlhint, andci-test-node-stop-commands.test.shandrun-hygiene-gate.test.shneed PyYAML.affected-tests.shreports the 12 shell copies as UNMAPPED, so once the PR is ready the plan runs the whole shell corpus (a warning, not a failure).ci-workflows5e18f3d): the ShellCheckrun.sh, given this diff andEXCLUDE=.githooks/guardrails/, checks only the test file and exits 0. The machine-path script with the new exclude list reports no.githooks/line; before the change it reportedmachine-path-patterns.sh:41andhardcoded-path-patterns.sh:37.Known defects, upstream (#9426):
reference-verifyskipped.githooks/guardrails/hook-utils.sh(238,555 bytes, a new file sent whole) on this branch's push withArgument list too longand still passed (item 4); the CLI-flag noise above. The copies are not edited in place: they are plugin-owned and a release refresh would overwrite the change.Related
checks.*.declinedkeys and makesrepos-syncrunlefthook installafter clone or fast-forward.🤖 Generated with Claude Code