I managed to whip up a script to get the module signature of a file using Merlin’s (2.5.4 only) inference: https://gist.github.com/yawaramin/b86557ae81cbd019fcb9e071abe594de
You can use it like: sig src/foo.ml
And it will print the signature to stdout. This is useful for reading into an editor. E.g., with vim I can open a new signature file :e foo.mli
and then do :r !sig %
to immediately read in the signature.