I have been cleaning it up manually and had the same question. I suppose one could write a script that uses nbdev_diff_nbs to spot the modules that do not come from an export.
If you’re working on Windows, do keep in mind that nbdev_diff_nbs doesn’t work so you would need to write your own Powershell or CmdLet script from scratch.
It’s not really possible to do safely. We have no way to know which files you auto-generated with some older file and no longer want to keep, vs which ones are files you’ve created manually and do want to keep.
The first thing that occurred that could work was to look at the comment in the first line, where it mentions it’s generated.
It would likely make the implementation slower and more convoluted, but could be an interesting separate command for clean up?
EDIT: I understand how this may not be a good practice sharing just for brainstorming/discussing.
EDIT2: To clarify, I am not suggesting deleting without prompt, just an extra check/reminder that could help keep the library clean