What is the ruling on insulting and mocking by way of joking?
Question

What is the ruling on friends mocking one another by way of joking, meaning that I trade insults with my friend jokingly, when there is no fear of that stirring up enmity?
Praise be to Allah.Mocking or lampooning means reviling and listing a person’s faults. It is mostly done in poetry, but it may be done in poetry and otherwise. al-Mu‘jam al-Wasit (2/975).
There is a clear prohibition on insulting a Muslim. It was narrated from Ibn Mas‘ud (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “Trading insults with a Muslim is evildoing and fighting him is disbelief (kufr).” Al-Bukhari (48).
An-Nawawi (may Allah have mercy on him) said: The Arabic word sabb (reviling) means insulting and saying about the person things that shame him. Reviling someone for no legitimate reason is prohibited, according to the consensus of the ummah, and the one who does that is an evildoer, as the Prophet (blessings and peace of Allah be upon him) said."(Sharh an-Nawawi ‘ala Muslim  2/53).
If it so happens that the insult is said by way of joking, that is not allowed either, because such insults are usually wrong and foul-mouthed. In the hadith it is narrated that Abu Hurayrah said: They said: O Messenger of Allah, you joke with us. He said: “I never say anything but that which is true.” At-Tirmidhi (1990); he said: This is as hasan sahih hadith. It was also classed as sahih by al-Albani in as-Silsilah as-Sahihah (1726).
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) was asked: It is customary for friends to joke, and those jokes include saying rude words. Is this regarded as prohibited?
He (may Allah have mercy on him) replied: Yes, rude words which include false accusations, cursing and the like, are prohibited, even if they are said by way of joking, because the Muslim has sanctity and it is not permissible to violate that sanctity."(Fatawa Nur ‘ala ad-Darb by al-‘Uthaymin  24/2).
It makes no difference whether the insult comes in the form of poetry or prose; rather poetry has more impact, because it is easy to memorize and circulate.
Secondly:
Your saying that you mock one another jokingly when there is no fear of that stirring up enmity is not correct, because it is well established for people of reason that people are affected by what is said about them, even if they pretend otherwise because it is said as a joke. Rather it is said that what a person cannot say in earnest he will say as a joke. Educationalists and behaviourists have stated that the impact of such words remains in the psyche. Hence Allah, may He be exalted, says (interpretation of the meaning): {And tell My servants to say that which is best} [al-Isra’ 17:53]. This indicates that speaking unkind words is a means by which the Shaytan sows discord among people, whether the words are said in earnest or in jest. Real-life experience tells us how often jokes create grudges, enmity and rancour, so how about if the jokes include insults and mockery?
Hence it is not appropriate for you to mock one another, even if that is by way of joking; rather you should let your joking be by saying good and permissible words. According to the hadith, the Prophet (blessings and peace of Allah be upon him) said: “The Muslim is the one from whose words and actions the Muslims are safe.” Narrated by al-Bukhari (10).
And Allah knows best.