Yazid bin Hurmuz reported,

Najdah wrote to Ibn Abbas asking him about certain matters, and he reported a hadith similar to that of Sulayman bin Bilal, except that in Hatim's version it states, "The Messenger of Allah ﷺ did not kill children, so do not kill children unless you know about a child what Khidr knew about the boy he killed."Ishaq added in his version from Hatim, "And you distinguish the believer, killing the disbeliever and sparing the believer."

Muslim 4685

Sahih

حدثنا أبو بكر بن أبي شيبة وإسحق بن إبراهيم كلاهما عن حاتم بن إسمعيل عن جعفر بن محمد عن أبيه

عن يزيد بن هرمز

أن نجدة كتب إلى ابن عباس يسأله عن خلال بمثل حديث سليمان بن بلال غير أن في حديث حاتم وإن رسول الله ﷺ لم يكن يقتل الصبيان فلا تقتل الصبيان إلا أن تكون تعلم ما علم الخضر من الصبي الذي قتل وزاد إسحق في حديثه عن حاتم وتميز المؤمن فتقتل الكافر وتدع المؤمن

مسلم 4685صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Jihad and expeditions
Chapter
Women who participate in military expeditions are given a share but not a full portion, and the prohibition of killing the children of the enemy
Numbering
Darussalam 4685
Muslim 4685