I heard the Messenger of Allah ﷺ say, "The first thing Allah created was the Pen. He said to it, 'Write,' and so it recorded everything that will exist for all eternity."The hadith contains a story. He said this is a hasan sahih gharib hadith, and there is a narration on this topic from Ibn Abbas.
حدثنا يحيى بن موسى حدثنا أبو داود الطيالسي حدثنا عبد الواحد بن سليم قال قدمت مكة فلقيت عطاء بن أبي رباح فقلت له يا أبا محمد إن أناسا عندنا يقولون في القدر فقال عطاء لقيت
سمعت رسول الله ﷺ يقول إن أول ما خلق الله القلم فقال له اكتب فجرى بما هو كائن إلى الأبد وفي الحديث قصة قال هذا حديث حسن صحيح غريب وفيه عن ابن عباس
No references are available.
[Sahih], previously mentioned: 2155 * And on this topic there is a narration from Ibn Abbas [Abu Yaala: 4/217, no. 2329, and Bayhaqi: 3/9].