The last 6 months I have been working in a small company that has a nice and relaxed work environment; the teamwork is good and we sometimes joke on each other as in "water-cooler" moments. One of my coworkers (call him John, 3 years working there) is the one that makes most of the jokes, saying that it "helps the team to relax and prevent work-related stress".
The most recurrent kind of jokes John makes are those that, in a sarcastic manner, put in doubt your technical and professional skills, but actually mean the opposite. For example he may say: "you are a terrible programmer", when he actually wanted to convey the message: "you are a good programmer".
Some days ago we were in a critical work situation: John had some data analysis due that day and wanted to use a program I developed to make them instead, without ever having used or studied the program before (which is also not ready for production yet).
This led us to some strong arguing about the program not working at all, but after explaining him how to correctly use it the problem stopped escalating. Immediately after this (still both a bit tense) he threw one of those jokes at me, saying: "Still, I doubt this is going to work when it is finished..."
In another situation perhaps this joke would have been "tolerable" (no sexual or racist content), but in this case it sounded more like an insult rather than sarcasm. Some seconds after saying it John laughed, so I then knew he was only joking... However, this could have started another argument or escalated the problem even more. After some days of thinking it over and over, here are the questions I have:
What would be a polite way of telling John to refrain from joking during critical moments?
Is there something that could be done to prevent these kind of jokes from turning into a negative situation, in critical and non-critical moments?
I don't want to be a party pooper and cut all jokes out.