Your comments

This would be classical use case for a pre-commit hooks, easy if you just want to check the staged files, a bit more complicated if you just want to check the changed lines.