Anas reported: The Messenger of Allah صلى الله عليه وسلم said, “If Allah intends good for a servant, He puts him into action.” It was said, “How does he put him into action, O Messenger of Allah?” He said, “By making him meet up with righteous deeds before death.”
[Sunan At-Tirmidhi, Book 30, Number 2142, Grade: Sahih]
Book of Divine Destiny, Chapter: What is related about what is written for the people of Paradise and Hell
عَنْ أَنَسٍ قَالَ قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ إِذَا أَرَادَ اللَّهُ بِعَبْدٍ خَيْرًا اسْتَعْمَلَهُ فَقِيلَ كَيْفَ يَسْتَعْمِلُهُ يَا رَسُولَ اللَّهِ قَالَ يُوَفِّقُهُ لِعَمَلٍ صَالِحٍ قَبْلَ الْمَوْتِ
قَالَ أَبُو عِيسَى هَذَا حَدِيثٌ حَسَنٌ صَحِيحٌ
سنن الترمذي كتاب القدر عن رسول الله صلى الله عليه وسلم باب ما جاء أن الله كتب كتابا لأهل الجنة وأهل النار