Imam's (as) know their followers before their creation

There are many narrations which say that the Allah (swt) put forth the spirits of all the creations before creation of their bodies in front of Prophet Muhammad (saww) and the Imam's (as) and made the Prophet (saww) and the Imam's (as) know those who love them and those who hate them.

حدثنا حسن بن على بن عبد الله بن المغيرة قال حدثنا عبيس بن هشام عن عبد الكريم عن سماعة بن مهران عن ابى عبد الله عليه السلام قال بينا امير المؤمنين في مسجد الكوفه إذ اتاهرجل فقال يا امير المؤمنين والله انى لاحبك قال ما تفعل قال والله انى لاحبك قال ما تفعل قال بلى والله الذى لا اله الا هو قال والله الذى لا اله الا هو ما تحبنى فقال يا امير المؤمنين انىاحلف بالله انى احبك وانت تحلف بالله ما احبك والله كانك تخبرني انك اعلم بما في نفسي فغضب امير المؤمنين عليه السلام وانما كان الحديث العظيم يخرج منه عند الغضب قال فرفعيده إلى السماء وقال كيف يكون ذلك وهو ربنا تبارك وتعالى خلق الارواح قبل الابدان بالفى عام ثم عرض علينا المحب من المبغض فوالله ما رايتك فيمن احبنا فاين آنت

Narrated to us Hassan Bin Ali Bin Abdullah Bin Al-Mugheira, from Ubeys Bin Hashaam, from Abdul Kareem, from Sama’at Bin Mahraan who has said:

Abu Abdullah (as) said, "Amir-ul-Momineen (as) was giving a sermon in the Masjid of Al-Kufa, when a man came up and said, ‘O Amir-ul-Momineen (as), by Allah (swt), I love you (as)."

He (as) said, You do not. He said, By Allah (swt), I do love you.

He (as) said, You do not. He said, Yes, by Allah (swt) besides Whom there is no god but Him.

He (as) said, By Allah (swt) besides Whom there is no god but Him, you do not love Me. He said, ‘O Amir-ul-Momineen (as), I swear by Allah (swt) I love You and You swear by Allah (swt) that I do not love You, and it is as if You are informing me that You know what is in my soul?

Amir-ul-Momineen (as) got angry, and it was a great narrative that came out of Him because of him being angry. He raised His

hands towards the sky and said: How can that be, and He is our Lord Blessed and High, Who Created the souls before the bodies by a thousand years, Presented to Us the lover and the hater, for, by Allah (swt), I did not see you among those that love Us. Where were you?

[Source: Basaair Al-Darajaat, Vol. 2, Chapter. 15, Hadees. 4]

Hadees is Hasan (Reliable) as per chain of narrators.

حدثنا احمد بن محمد ومحمد بن الحسين جميعا عن الحسن بن محبوب عن على بن رئاب عن بكير بن اعين قال كان أبو جعفر عليه السلام يقول ان الله اخذ ميثاق شيعتنا بالولاية لنا وهم ذر يوم اخذ الميثاق على الذر والاقرار له بالربوبية ولمحمد صلى الله عليه وآله بالنبوة وعرض الله على محمد امته في الطين وهم اظلة وخلقهم من الطينة التى خلق منها آدم وخلق الله ارواح شيعتنا قبل ابدانهم بالفى عام وعرضهم عليه وعرفهم رسول الله وعرفهم عليا ونحن نعرفهم في لحن القول

Narrated Ahmad ibn Muhammad and Muhammad bin Husain from Hasan bin Mahbub from Ali bin Riab from Bukayr bin Ayan who has said the following:

"Abu Ja‘far (as) would say, "Allah made our Shia to make a covenant to acknowledge our Walaya when they were small particles. It was the day when He made all particles to make a covenant to acknowledge Him as the Lord and Muhammad (saww) as the Prophet. Allah, the Most Majestic, the Most Gracious, presented to Muhammad his Umma (followers) in clay and they were shadows. He created them from the clay out of which Adam (a.s) was created. Allah created the spirits of our Shia two thousand years before their bodies were created. He presented them to the Holy Prophet (saww) and Messenger of Allah (saww) recognized them and Ali (as) recognized them and we recognize them by the tone of their speech."

[Source: Basaair Al-Darajaat, Vol. 2, Chapter. 16, Hadees. 1 & Al-Kafi, Vol. 1, Pg. 438]

Hadees is Hasan (Reliable) as per chain of narrators. See Mirat Al-Uqool - Allama Majlisi, Vol. 5, Pg. 166

There are many more such narration with similar content (matn).