You deskew it in GIMP? Sure, you want automation, but...
How is unpaper "The FOSS tool to deskew" when it "often" fails to do just that?
The unpaper options are not well explained.
There's https://manpages.org/unpaper and https://github.com/unpaper/unpaper/tree/main/doc
The various --deskew-* options seem well explained to me.
apt search deskew returns ocrmypdf and pagetools, no idea if that all goes back to unpaper or not.