How to detect whether a video is shaky
Try ffmpeg's deshake filter. It scans the full frame (or a portion of your choosing) and detects shake based on a number of adjustable variables. If the video isn't shaking, it doesn't change the content. You can run the default settings with:

ffmpeg -i [input] -vf deshake [output]

Great little demo here. It's a combination detection and repair tool, no need to separately identify videos then reprocess.