Here’s the minimalist code I can think of to help avoid accidentally running code on the wrong server.
PRINT @@servername;
IF @@servername <> 'SomeServerName' RETURN;
I like it because it stays out of the way within the ‘messages’ tab, and is somewhat subliminal when checking things like “rows affected”.
Hopefully I will remember to paste it near the top of the code I work on 🙂