1.7 KiB
SPEC: Git Pre-Commit Hook for Task Enforcement
Overview
The .rules.md says "All changes must go through a task in tasks/{name}/" but nothing enforces it. The agent repeatedly makes ad-hoc edits and only creates tasks retroactively (or not at all). A pre-commit git hook mechanically blocks commits that lack a corresponding task.
Root Cause
The rule is passive (a file on disk) and relies on the agent remembering to check it. Every session starts fresh — past failures don't carry over. The agent has no active enforcement.
Solution
A scripts/pre-commit-hook.sh that:
- Gets the list of changed files (staged + unstaged)
- Checks if there's a task in
tasks/whose SPEC.md keywords match the changed files - If no matching task found, prints the changed files and asks: "Continue without a task? (y/N)"
- If the user says no, exits non-zero and blocks the commit
The hook is installed via scripts/install-hooks.sh which copies it to .git/hooks/pre-commit.
Files
scripts/pre-commit-hook.sh— the hook scriptscripts/install-hooks.sh— installer
Acceptance Criteria
scripts/pre-commit-hook.shblocks commits that change files without a matching taskscripts/install-hooks.shinstalls the hook into.git/hooks/pre-commit- Hook allows commits when user confirms (y) despite no task
- Hook allows commits when a matching task exists in tasks/
- README updated to mention hook installation
Why This Fix Works
A pre-commit hook runs before every commit. The agent cannot bypass it without intentionally deciding to — and even then, the prompt forces conscious acknowledgment ("Continue without a task?") rather than simply forgetting.