Implement the 006-pre-commit-gate feature that enforces a pre-commit quality gate using Lefthook to run pnpm check before every commit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-05 11:44:44 +01:00
parent fea2bfe39d
commit 0bbd6f27f9
11 changed files with 483 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
# Quickstart: Pre-Commit Gate
## What This Feature Does
Adds a Git pre-commit hook (managed by Lefthook) that runs `pnpm check` before every commit. If any check fails, the commit is blocked.
## Files to Create/Modify
| File | Action | Purpose |
|------|--------|---------|
| `lefthook.yml` | Create | Lefthook configuration with pre-commit hook |
| `package.json` | Modify | Add `lefthook` devDependency + `prepare` script |
## Setup After Implementation
After the feature is implemented, hooks activate automatically:
```bash
pnpm install # installs lefthook + runs `prepare` which calls `lefthook install`
```
## How It Works
1. Developer runs `git commit`
2. Lefthook intercepts via the Git pre-commit hook
3. Lefthook runs `pnpm check` (format + lint + typecheck + test)
4. If `pnpm check` exits 0 → commit proceeds
5. If `pnpm check` exits non-zero → commit is blocked, output shown
## Bypass
```bash
git commit --no-verify # skips the pre-commit hook
```