Hook usage (consuming repositories)
How to add a2c-pre-commit-hooks to an A2C-governed software repository.
Prerequisites
-
pre-commit installed (
pip install pre-commit) -
Root-level
CHANGELOG.md(Keep a Changelog format) -
Git hooks installed in the consuming repo:
pre-commit installpre-commit install --hook-type merge-commit
Add the hook
Create or extend .pre-commit-config.yaml at the repository root:
repos:
- repo: https://gitlab.com/libesys/ai-workflows/a2c-pre-commit-hooks.git
rev: v0.2.0
hooks:
- id: check-changelog
- id: validate
Replace rev with the latest release tag.
The validate hook installs a2c-cli from PyPI
(version pinned in pyproject.toml [project.optional-dependencies.validate], currently
0.2.1). Pre-commit pulls it via the .[validate] extra declared in
.pre-commit-hooks.yaml — only when validate is enabled.
Override the CLI version in your .pre-commit-config.yaml when needed:
- id: validate
additional_dependencies:
- a2c-cli==0.2.1
Or install the extra locally: pip install -e ".[validate]" in a clone of this repository.
SSH remotes
If your environment uses GitLab SSH (git@gitlab-ai:...):
- repo: git@gitlab-ai:libesys/ai-workflows/a2c-pre-commit-hooks.git
rev: v0.2.0
hooks:
- id: check-changelog
- id: validate
What check-changelog enforces
When you run git commit (or merge-commit hooks):
| Staged files | Result |
|---|---|
| (none) | Pass |
Only CHANGELOG.md | Pass |
CHANGELOG.md + other files | Pass |
Other files without CHANGELOG.md | Fail |
Other files, no CHANGELOG.md on disk | Fail (create changelog first) |
The hook inspects the Git index (staged files), not unstaged working-tree edits.
Typical workflow
-
Make code or documentation changes.
-
Update
## [Unreleased]inCHANGELOG.mdfor release-relevant work. -
Stage everything:
git add src/my_module.py CHANGELOG.mdgit commit -m "feat(app): Add export endpoint" -
If you forget the changelog, the hook prints a message and blocks the commit.
Changelog-only commits
Documentation or release prep that touches only the changelog is allowed:
git add CHANGELOG.md
git commit -m "docs(changelog): Curate unreleased notes"
What validate enforces
When enabled, the hook runs a2c validate on the repository root (repo-wide, not per staged
file). It checks A2C config, workflow manifest, planning epics/tasks/sprints, unique ids, and
cross-references.
| Outcome | Hook result |
|---|---|
| Valid A2C repository | Pass |
| Validation errors in planning artifacts | Fail (exit 1) |
| Not inside an A2C repository | Fail (exit 2) |
Use this hook only in A2C-governed repositories that already use the a2c CLI.
pre-commit run validate
Optional hook arguments
- id: check-changelog
args: [--changelog-file, CHANGELOG.md]
Use a different path only when your project standard explicitly places the changelog elsewhere
(A2C default is repository root CHANGELOG.md).
For validate:
- id: validate
args: [--repo-root, .]
Manual run
Run on staged changes without committing:
pre-commit run check-changelog
Run against all files is not the default CI pattern for consuming repos; use normal commit-time hooks locally.
Updating the hook version
-
Check release tags.
-
Bump
revin.pre-commit-config.yaml. -
Refresh cached environments:
pre-commit autoupdate --repo https://gitlab.com/libesys/ai-workflows/a2c-pre-commit-hooks.git# or: pre-commit clean && pre-commit run check-changelog
Troubleshooting
| Symptom | Likely cause |
|---|---|
| Hook not found | Wrong rev or repo URL; verify tag exists |
| Fails despite editing changelog | CHANGELOG.md edited but not staged (git add CHANGELOG.md) |
| SSL / clone errors | On Windows run scripts/fix-git-ssl.ps1 from this repo (or the copy in your consuming repo if mirrored); use SSH repo URL for GitLab; see development.md |
a2c-cli is not installed | Enable validate in .pre-commit-config.yaml; run pre-commit clean after upgrading hook rev |
| Validate import / pip errors | Pin a2c-cli==0.2.1 (or newer) under validate → additional_dependencies; ensure PyPI access |
| Windows path issues | Hook normalizes paths; ensure changelog path uses forward slashes in config |