Ubada bin Samit reported,

I heard the Messenger of Allah ﷺ say, "The first thing Allah created was the Pen. He said to it, 'Write.' It asked, 'My Lord, what shall I write?' He said, 'Write the decrees of everything until the Hour comes.'"

Azami 12808

Hasan

عن عبادة بن الصامت قال

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

الأعظمي 12808حسن
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Tafsir of the great Quran
Chapter
Tafsir of Surah Anbiya
Section
His saying, "Did you not know that Allah has power over all things" meaning that the knowledge of Allah encompasses everything in the heavens and the earth, and that all of that is written in a Book with Him, as has been narrated in the hadith
Numbering
Jami al-Kamil 12808 (2nd edition)
Azami 12808