Adding a post_save_hook with an extension?

Is it possible to add a post_save_hook via an extension?

Currently I use a post_save_hook that calls nbconvert to convert the file to a .py file, then modify that file to strip out output text as well as also stripping out any code cells that do not being with “#@!” (an arbitrary comment that I picked).

This automatically saves just the selected cells (that start with #@!) in a notebook to a corresponding python file, while still allowing me to keep other cells in just the .ipynb file but out of the .py file (such as snippets for testing). It also means that I can essentially just call other notebooks through standard Python mechanics, which then makes it much, much easier to deploy the code.

Unfortunately this setup requires me to re-add the post_save_hook when I occasionally create a new Jupyterlab instance, and is perhaps a touch clunky having to add #@! to the cells that I want to save to the python file.

What I’d ideally like to do is to create an extension that adds a new cell type (CodeToSave or something like that), which would act identically to a Code cell within a notebook, but then the post_save_hook would only save those to the .py file (so skipping the need for #@!). While I’ve found some information on adding new cell types through an extension, I haven’t been able to find out if there is a way (and if so how) to add a post_save_hook via an extension. Is it possible?