Abdullah bin Abbas reported,

He used to narrate that the Messenger of Allah ﷺ said, "The first thing Allah created was the Pen, and He commanded it to write everything that would come to be."

Azami 993

Sahih

عن ابن عباس

أنه كان يحدث أن رسول الله ﷺ قال: إن أول ما خلق الله القلم، وأمره أن يكتب كل شيء يكون.

الأعظمي 993صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Faith
Chapter
Belief in the divine decree and predestination
Section
First thing Allah created was the pen and He commanded it to write the measures of all things until the Hour is established
Numbering
Jami al-Kamil 993 (2nd edition)
Azami 993