Anas bin Malik reported,

The Prophet ﷺ said, "Allah عز وجل has appointed an angel over the womb. The angel says, 'My Lord, a drop of fluid. My Lord, a clinging clot. My Lord, a lump of flesh.' Then, when Allah wills to complete its creation, the angel asks, 'Male or female? Wretched or blessed? What provision? What term of life?' All of this is then written while the child is still in its mother's womb."

Azami 12772

Sahih

عن أنس بن مالك

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

الأعظمي 12772صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Tafsir of the great Quran
Chapter
Tafsir of Surah Anbiya
Section
His saying, "doon the people, then wish for death if you are truthful"
Numbering
Jami al-Kamil 12772 (2nd edition)
Azami 12772