All Praise to Allah Subhanahu wa Taala and blessings of Him be on Prophet Muhammad peace be upon him His family and companions,
Sharia ruling of Magic:
Imam Nawawi Ra has written:To do Magic is Haram and is one of the major Sin as Rasulullah SalAllahu alayh wasallam has included it with seven destructive acts.To learn and teach Magic is Haram too.If the spell or cast of the magician comprises something with kufr then it would be regarded as Kufr otherwise not and would be considered as a major sin.Similar ruling goes with learning or teaching the Magic.In our view the magician would not be get killed but would be asked for the repentance if he repents then his repentance would be accepted.Ibn Hajar Asqalani Shafii Ra has written the same.(Fath ul Bari)
Imam Nawawi Ra has written that some of our fellows consider as permissible to learn the magic so he could know about it and can avoid the damage caused due to magic.
Maliki View:Dardir Maliki Ra has written:In View of Imam Radi Allahu anhu to learn and teach Magic is Kufr whether it casts the spell or not because to venerate shayateen is something an act that that no sane muslim could dare to say that this act is not kufr.To treat the magic with magic is also kufr.Someone coud be appointed to treat the magic in a condition that it would not be treated with magic itself.If Quranic verses or Names of Allah Swt are used for something then it is not kufr but to creat mischief among people by means of magic or to hurt someone's property by magic would be haram.If someone affirmly does magic he should get killed unless he repents.
Hanbali View:Ibn Qadam Ra has written:To learn and teach magic is haram and we consensually consider the takfir for the magician whether the magician believes it to be haram or mubah,There is one narration from Imam Ahmad Ra to avoid the takfir beacause he mentioned that the magician should be asked for the repentance ,lawfully they are apostate but if they repent then they should be left free.Narrator asked what if he doesnt repent should he then get killed Imam Ra replied No,He should get prisoned until he repents as till he prays there are chances for his repentance.
Hanafi View:Ibn Hamam hanafi Ra has written:To teach magic is haram consensually and to believe it as correct is Haram.Some of our fellows believe that the magician should get death penalty whether he believes it to be haram or not.Narrated Jundab:That he heard the Messenger of Allah (ﷺ) saying: "The punishment of the Sahir is a strike of the sword."(Tirmidhi)[Fath ul Qadir]
Allama Shami Hanafi Ra has written:if the magician work does not involve kufr then there would be no takfir on him ,Imam abu hanifa ra said if the sihr of magician is proved by his affirmation and witness then he would be get killed and would not be asked for the repentance.
Allah Haskafi hanafi Ra has written:If the magician has repented before he got caught then his repentance would be accepted and would not get death penalty otherwise repentance would not be accepted and would get the penalty.(Durr e Mukhtar)
In view of Imam Malik ,Ahmad,abu Hanifa Ra the magician is under the ruling as a robber and would be given the death penalty,In view of Imam Shaafii Ra he would not be given the death order.
Allah swt and His Messenger knows best.