Shafi qualified from Cambridge University and the Royal Free Hospital School of Medicine with Honours in 1997. He was awarded a British Heart Foundation Junior Research Fellowship in 2001 to study the modulation of vasospasm in radial artery bypass grafts. He was awarded a doctorate by Cambridge University in 2008.He trained in the generality of Cardiothoracic Surgery predominantly at Papworth Hospital, Cambridge before undertaking sub-specialty training in Congenital Cardiothoracic Surgery in Birmingham, London, and Paris.His interests are neonatal cardiac surgery, aortic surgery in adult congenital heart disease, and education and mentorship in congenital cardiac surgery.