0. Have a setup with composer with a the web folder not in the root folder and install code sniffer with
composer require drupal/coder
chmod -R 777 .githooks
git config core.hooksPath .githooks
chmod +x .githooks/pre-commit
Stuff that could be triggered on git push in this example.