Is there an RPC command that checks for hardforks
There is no way to explicitly know that your node is on a minority-hashrate fork because to do so would mean awareness of all the new rules that makes the majority-hashrate fork valid, and then determining that more proof-of-work is accumulated on that chain. For that to be possible, you must be running an upgraded node already.

There are a few warning signs though: If your node hasn't received a new block in over two hours for example, you might want to manually check it - does it still have a good number of peers? Does log activity look OK?

High-volume Bitcoin merchants and exchanges usually simultaneously run several Bitcoin nodes, even a few different versions (0.19, 0.18, 0.17) and maybe even an alternative implementation (bcoin, btcd). This is how BitMex' https://forkmonitor.info operates.

There is rpc getchaintips: https://chainquery.com/bitcoin-cli/getchaintips

...but this is doing the opposite of what you asked: it will reveal to the user known chain forks (stale blocks, etc) but of course they are all lesser-work than the node's current tip which is always on the most-work valid chain.