Skip to content

feat: add Lefthook local git-hooks module - #26

Merged
kyle-sexton merged 1 commit into
mainfrom
feat/lefthook-hooks
Jun 23, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
feat/lefthook-hooks

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Migrates medley's Lefthook setup into the platform as a strict, decoupled module — the remaining Phase 3 hooks item in docs/migration-plan.md. Re-derived from the official Lefthook v2 docs (not ported), verified empirically against the local lefthook 2.1.9 binary.

What's here

  • modules/lefthook/base.yml — cross-cutting hygiene lanes (typos, gitleaks, editorconfig, shellcheck, markdownlint), each backed by an existing modules/* ruleset.
  • Opt-in overlay fragments — lefthook-{powershell,python,typescript,dotnet}.yml, one per language overlay.
  • modules/lefthook/README.md — rationale, the decoupling/extensibility model, adoption manifest, engine/version notes.
  • modules/lefthook/lefthook.test.sh — behavioral test (temp git repo): a consumer that extends the base gets its lanes, a lane fires on a non-conforming staged file and passes a clean one, and skip: true opts a lane out without editing the base.
  • Root lefthook.yml — dogfood instance that extends every fragment.

Decoupling (the key decision)

standards forbids runtime coupling to itself, so distribution is copy + extends — a consumer's own root lefthook.yml extends the vendored fragments (the open/closed pattern the overlays already use). remotes: was rejected: it's a live git clone cached in .git/info/lefthook-remotes with a mandatory first-fetch — i.e. exactly the runtime coupling the platform forbids. Lanes are check-only (no stage_fixed) and path-free — each invokes a tool and lets it auto-discover its standards config from the repo root, so the hooks reference the existing rulesets rather than forking or re-configuring them.

Type-checkers (Pyright, tsc) and the .NET analyzer build stay CI-only (whole-project context; would double-report). No ci-workflows action is warranted — Lefthook is local-dev tooling; the only CI use is the dogfood lane below, run inline against a pinned lefthook npm devDependency (Dependabot-tracked).

CI

New lefthook lane: lefthook validate (parses + merges root + all fragments) plus the behavioral test; wired into the ci-status gateway.

🤖 Generated with Claude Code

Re-derived, strict, decoupled local git hooks that run the same tools the
overlays/scanners already standardize as fast, staged-only pre-commit checks
(CI stays the authoritative gate).

- modules/lefthook/base.yml: cross-cutting hygiene lanes (typos, gitleaks,
  editorconfig, shellcheck, markdownlint); opt-in per-language overlay fragments
  (powershell, python, typescript, dotnet) composed via extends.
- Decoupled by copy + extends (the open/closed pattern the overlays use), never
  remotes: (which would runtime-couple every consumer to this repo). Lanes are
  check-only and path-free, invoking tools that auto-discover their standards
  config from the repo root — no forking or re-configuring.
- Type-checkers (pyright, tsc) and the .NET analyzer build stay CI-only.
- No ci-workflows action: lefthook is local-dev tooling; the only CI use is a
  validate + behavioral-test lane run inline against a pinned lefthook npm dep.
- Dogfood: root lefthook.yml extends every fragment; the CI lefthook lane runs
  `lefthook validate` + modules/lefthook/lefthook.test.sh; wired into ci-status.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@kyle-sexton
kyle-sexton merged commit ff49d2c into main Jun 23, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the feat/lefthook-hooks branch June 23, 2026 15:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48d3734a9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lefthook.yml
Comment on lines +16 to +20
- modules/lefthook/base.yml
- modules/lefthook/lefthook-powershell.yml
- modules/lefthook/lefthook-python.yml
- modules/lefthook/lefthook-typescript.yml
- modules/lefthook/lefthook-dotnet.yml

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude bad fixtures from dogfood hooks

By composing the base and every overlay here without any root-level exclude overrides, this repo's Lefthook config also runs on staged files under fixtures/*/bad/** (for example the intentionally invalid Markdown, Python, PowerShell, shell, and .NET fixtures). Those files are deliberately non-conforming and the CI self-lint lanes exclude them, so any legitimate update to a bad fixture will be blocked locally by the dogfood hook; add matching bad-fixture excludes/skip overrides in the root config or avoid extending overlays for fixture-only languages.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant