#!/usr/bin/env bash # Pre-commit hook: enforce 10-line net addition limit # Install: git config core.hooksPath .githooks ADDITIONS=$(git diff --cached --numstat | awk '{s+=$1} END {print s+0}') DELETIONS=$(git diff --cached --numstat | awk '{s+=$2} END {print s+0}') NET=$((ADDITIONS - DELETIONS)) if [ "$NET" -gt 10 ]; then echo "BLOCKED: Net addition is $NET lines (max: 10)." echo " Delete code elsewhere to compensate." exit 1 fi echo "✓ Pre-commit: net $NET lines (limit: 10)"