“How does plainclothes cops survive encounters with uniformed cops they don’t know?”
If at all possible they try not to have gun in hand. They identify themselves immediately with whatever the local lingo is. And they live by the iron rule, the uniformed cop is the boss... they do exactly as they command with zero argument.
To do otherwise is to court disaster.
It’s akin to a recon patrol returning and making contact with a friendly perimeter. Very very deadly if done wrong.
I believe for NYPD there used to be a color of the day. Don’t know if this is still done.