#!/bin/sh # Git pre-commit hook: block commits that stage source files without updating README.md + CLAUDE.md. # Installed to .git/hooks/pre-commit by scripts/install-hooks.sh. STAGED=$(git diff --cached --name-only) # Only enforce when at least one source file is changing SOURCE_CHANGED=$(echo "$STAGED" | grep -E '\.(py|js|html|css)$' | grep -v '^tests/' | head -1) [ -z "$SOURCE_CHANGED" ] && exit 0 README_STAGED=$(echo "$STAGED" | grep '^README\.md$') CLAUDE_STAGED=$(echo "$STAGED" | grep '^CLAUDE\.md$') if [ -z "$README_STAGED" ] || [ -z "$CLAUDE_STAGED" ]; then echo "" echo " Commit blocked: source files staged but docs not updated" echo "" [ -z "$README_STAGED" ] && echo " • README.md not staged" [ -z "$CLAUDE_STAGED" ] && echo " • CLAUDE.md not staged" echo "" echo " Update both to reflect your changes, git add them, then retry." echo " Bypass with: git commit --no-verify" echo "" exit 1 fi exit 0