Allah has assigned an angel to the womb. The angel says, "My Lord, a drop of fluid. My Lord, a clot. My Lord, a lump of flesh." When Allah wishes to decree the creation of a being, the angel asks, "My Lord, male or female? Wretched or blessed? What is his provision? What is his lifespan?" All of this is then written while he is still in his mother's womb.
حدثني أبو كامل فضيل بن حسين الجحدري حدثنا حماد بن زيد حدثنا عبيد الله بن أبي بكر
إن الله عز وجل قد وكل بالرحم ملكا فيقول أي رب نطفة أي رب علقة أي رب مضغة فإذا أراد الله أن يقضي خلقا قال قال الملك أي رب ذكر أو أنثى شقي أو سعيد فما الرزق فما الأجل فيكتب كذلك في بطن أمه