Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .lefthook/commit-msg/commit-msg-lint.sh
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,32 @@ 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

1. Go to the [template repository](https://github.com/new?template_owner=iap&template_name=.github).
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/<hook-name>/`. Override with `git commit --no-verify` when needed.

## License

This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
22 changes: 22 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -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
Loading