---
id: T-004
name: Install pre-commit hook for task enforcement
description: >
  Create a git pre-commit hook that validates commit messages contain task references
  (T-XXX pattern). This provides structural enforcement per D2 Reliability.
status: work-completed
workflow_type: build
owner: human
priority: medium
tags: [enforcement, git, D2]
agents:
  primary:
  supporting: []
created: 2026-02-13T18:13:16Z
last_update: '2026-06-11T22:23:35Z'
date_finished: 2026-02-13T19:47:00Z
bvp_scores_proposed:
  - ts: '2026-06-11T22:23:35Z'
    estimator: bvp-estimator-v1-heuristic
    scores:
      D1: 0
      D2: 1
      D3: 0
      D4: 0
      F-RECALL: 0
      F-ORCH: 0
      F3: 0
      F1: 0
      F2: 0
    rationale: D1=0 (no-signal); D2=1 (body:log-or-error-line); D3=0 
      (no-signal); D4=0 (no-signal); F-RECALL=0 (no-signal); F-ORCH=0 
      (no-signal); F3=0 (no-signal); F1=0 (no-signal); F2=0 (no-signal)
    rubric_sha: e4a00f38e801
---

# T-004: Install pre-commit hook for task enforcement

## Design Record

Per P-002 (Structural Enforcement Over Agent Discipline), we cannot rely on agents/humans to remember task references. A git pre-commit hook provides structural enforcement.

**Design decisions:**
- Hook checks commit message for T-XXX pattern
- Allows bypass with `--no-verify` (Tier 2 bypass - logs warning)
- Does NOT block merge commits or rebase
- Provides helpful error message with task-create command

**Not in scope (future):**
- Validating task file exists
- Checking task status
- Tier 0 action blocking (that's a different hook)

## Specification Record

**Acceptance criteria:**
- [ ] `.git/hooks/pre-commit` exists and is executable
- [ ] Commit without task reference is blocked with helpful message
- [ ] Commit with task reference (T-XXX) succeeds
- [ ] `--no-verify` bypass works but logs warning
- [ ] Merge commits are allowed (no task ref required)
- [ ] Audit agent passes (no "pre-commit hook missing" warning)

**Hook behavior:**
```
If commit message does NOT contain T-[0-9]+:
  - Print error: "Commit blocked: No task reference found"
  - Print help: "Add task reference: git commit -m 'T-XXX: description'"
  - Print help: "Create task: ./agents/task-create/create-task.sh"
  - Print help: "Bypass (emergency): git commit --no-verify"
  - Exit 1
Else:
  - Allow commit
  - Exit 0
```

## Test Files

- Test: commit without task ref → blocked
- Test: commit with T-001 → allowed
- Test: merge commit → allowed
- Run `./agents/audit/audit.sh` → no hook warning

## Updates

### 2026-02-13T18:13:16Z — task-created [task-create-agent]
- **Action:** Created task via task-create agent
- **Output:** /opt/999-Agentic-Engineering-Framework/.tasks/active/T-004-install-pre-commit-hook-for-task-enforce.md
- **Context:** Initial task creation

### 2026-02-13T19:47:00Z — work-completed [claude-code]
- **Action:** Completed via git agent install-hooks command
- **Output:** .git/hooks/commit-msg and post-commit installed
- **Context:** Absorbed into T-013 (git agent), uses commit-msg hook (not pre-commit) for message validation

## Reviewer Verdict (v1.5)

- **Scan ID:** R-9a142c61
- **Timestamp:** 2026-06-02T14:53:58Z
- **Catalogue:** v1.3-seed
- **Overall:** PASS
- **Needs Human:** no
- **Findings:** none
