Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:18:74

So they set out, until when they met a boy, al-Khidh r killed him. ˹Moses˺ said, "Have you killed a pure soul for other than ˹having killed˺ a soul? You have certainly done a deplorable thing."  

So they set off, after leaving the ship, making their way on foot, until, when they met a boy, who had not yet reached puberty, playing with ˹other˺ boys, among whom his face was the fairest — and he, al-Khidr, slew him, by slitting his throat with a knife while he lay down, or by tearing his head off with his hand, or by smashing his head against a wall, all of which are ˹different˺ opinions (the coordinating fā’ ˹of fa-qatalahu, ‘and he slew him’˺ is used here because ˹it indicates that˺ the slaying took place after the encounter; the response to idhā, ‘when’ is ˹the following statement, qāla …˺) — he, Moses, said, to him: ‘Have you slain an innocent soul, that is, a pure one that had not reached the age of ˹legal˺ responsibility (a variant reading ˹for zākiya˺ has zakiyya), ˹one slain˺ not in retaliation for another soul?, in other words, one that has not slain any soul. Verily you have committed an dreadful thing’ (read nukran or nukuran), that is to say, an abomination.
القرآن:١٨:٧٤

فَانْطَلَقَا حَتَّىٰ إِذَا لَقِيَا غُلَامًا فَقَتَلَهُ قَالَ أَقَتَلْتَ نَفْسًا زَكِيَّةً بِغَيْرِ نَفْسٍ لَقَدْ جِئْتَ شَيْئًا نُكْرًا  

{فانطلقا} بعد خروجهما من السفينة يمشيان {حتى إذا لقيا غلاما} لم يبلغ الحنث يلعب مع الصبيان أحسنهم وجها {فقتله} الخضر بأن ذبحه بالسكين مضطجعا أو اقتلع رأسه بيده أو ضرب رأسه بالجدار، أقوال وأتى هنا بالفاء العاطفة لأن القتل عقب اللقاء وجواب إذا {قال} له موسى {أقتلت نفسا زاكية} أي طاهرة لم تبلغ حد التكليف وفي قراءة زكية بتشديد الياء بلا ألف {بغير نفس} أي لم تقتل نفسا {لقد جئت شيئا نكرا} بسكون الكاف وضمها أي منكرا.