Generalized pre-commit hook