Test-Driven Hook Debugging When a shell hook has subtle logic bugs (e.g., git operations failing silently in non-repo contexts), write a focused test suite in Python using to call the hook in controlled scenarios. Run tests to see the failure mode, then trace the gap between test expectations and hook behavior. Use guard clauses (e.g., before ) to handle edge cases. Re-run tests atomically after each fix to confirm the change. This approach isolates the bug and prevents regressions better than manual testing. ---