Whenever a developer modified an API payload contract in src/Contracts/, downstream consumers frequently broke because unit tests mocked the contract instead of asserting on real contract fixtures.
#!/usr/bin/env bash
# .git/hooks/pre-push
changed_contracts=$(git diff --name-only origin/main...HEAD | grep '^src/Contracts/')
if [ -n "" ]; then
changed_tests=$(git diff --name-only origin/main...HEAD | grep '^tests/Contracts/')
if [ -z "" ]; then
echo "REJECTED: Contract modified without corresponding tests in tests/Contracts/"
exit 1
fi
fi
Enforcing contract test modifications at git push time stopped breaking payload changes before they ever reached continuous integration.