From 70cf39fe88c0b519c93256a603ea4bafa360b74f Mon Sep 17 00:00:00 2001 From: Iko <6572003+iap@users.noreply.github.com> Date: Fri, 28 Aug 2026 21:20:45 +0700 Subject: [PATCH 1/2] docs(agents): add support notice --- AGENTS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index a5f914a..f2ba462 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,3 +1,5 @@ + + # AGENTS.md Instructions for AI coding agents working in this repository. From 42bb6054d65e3c41f29fc724fe19b3e1fedf2098 Mon Sep 17 00:00:00 2001 From: Iko Date: Fri, 28 Aug 2026 21:22:53 +0700 Subject: [PATCH 2/2] chore(ci): add lefthook git hooks manager Adds lefthook.yml with pre-commit (npm run lint) and commit-msg (type(scope): summary enforcement) hooks. Scripts live under .lefthook// per lefthook convention. README documents setup via 'lefthook install'. Config and hook behavior verified: valid messages accepted, invalid rejected, validate passes. --- .lefthook/commit-msg/commit-msg-lint.sh | 17 +++++++++++++++++ README.md | 19 +++++++++++++++++++ lefthook.yml | 22 ++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 .lefthook/commit-msg/commit-msg-lint.sh create mode 100644 lefthook.yml diff --git a/.lefthook/commit-msg/commit-msg-lint.sh b/.lefthook/commit-msg/commit-msg-lint.sh new file mode 100644 index 0000000..92310dd --- /dev/null +++ b/.lefthook/commit-msg/commit-msg-lint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Commit message validation — called by lefthook commit-msg hook. +# $1 is the path to the temporary commit message file. + +MSG=$(cat "$1") + +# Skip validation for merge commits +if echo "$MSG" | grep -qE '^Merge '; then + exit 0 +fi + +# Enforce type(scope): summary format per CONTRIBUTING.md +if ! echo "$MSG" | grep -qE '^(feat|fix|docs|chore|refactor|test)(\([a-z-]+\))?: .+'; then + echo "ERROR: commit message must match: type(scope): summary" >&2 + echo " Types: feat, fix, docs, chore, refactor, test" >&2 + exit 1 +fi diff --git a/README.md b/README.md index 0421be3..15c15a9 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ A starter template for new GitHub repositories. | `.github/workflows/ci.yml` | Generic GitHub Actions CI workflow (the `npm ci` and `npm test` steps skip when no `package.json` exists) | | `AGENTS.md` | Instructions for AI coding agents | | `CLAUDE.md` | Imports `AGENTS.md` so Claude Code picks up the same instructions | +| `lefthook.yml` | Git hooks manager config (pre-commit + commit-msg) | ## How to use @@ -20,6 +21,24 @@ A starter template for new GitHub repositories. 2. Create a new repository from this template. 3. Customize the files for your project. +## Git Hooks (Lefthook) + +This template includes `lefthook.yml` for git hook management. + +```bash +# Install lefthook (via mise or your package manager) +mise use lefthook + +# Install hooks into .git/hooks/ +lefthook install +``` + +Hooks configured: +- **pre-commit**: runs `npm run lint` if package.json exists (skips merge/rebase) +- **commit-msg**: enforces `type(scope): summary` commit message format via `.lefthook/commit-msg/commit-msg-lint.sh` + +Scripts live under `.lefthook//`. Override with `git commit --no-verify` when needed. + ## License This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details. diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..cf1d140 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,22 @@ +# Lefthook — git hooks manager +# Docs: https://lefthook.dev +# +# Install: lefthook install +# Validate: lefthook validate + +pre-commit: + commands: + lint: + run: | + # Run project lint if available + if [ -f package.json ] && command -v npm >/dev/null 2>&1; then + npm run lint + fi + skip: + - merge + - rebase + +commit-msg: + scripts: + "commit-msg-lint.sh": + runner: bash