Day 23: precommit

Welcome back for the 23rd day of the #packagecalendar, today we will be taking a look at the precommit package by Lorenz Walthert.

The package is not yet available from CRAN but can be downloaded with the following line of code. Also you need to have conda installed.


Once you installed what you need you just run


to initiate the use of pre-commit. Now every time you run git commit the hooks listed in your .pre-commit-config.yaml will be executed before the commit.

The package website includes a section on available hooks included in the package. This includes things like


Simply run precommit::open_config() to start configuring the hooks you want.

Lastly, I’ll quote a word of warning from the README > Do not abort while hooks are running. Non-staged changes are stashed to a temp directory when the hooks are run and may not easily be recovered afterwards.