The Messenger of Allah ﷺ came out to us holding two books in his hands and asked, "Do you know what these two books are?"We replied, "No, Messenger of Allah, unless you inform us."He said of the one in his right hand, "This is a book from the Lord of the Worlds containing the names of the people of Paradise, along with the names of their fathers and their tribes. Then a final summary was made of them all, so not one will ever be added to them nor one taken away."Then he said of the one in his left hand, "This is a book from the Lord of the Worlds containing the names of the people of the Fire, along with the names of their fathers and their tribes. Then a final summary was made of them all, so not one will ever be added to them nor one taken away."His companions asked, "Then what is the point of doing deeds, Messenger of Allah, if the matter has already been settled?"He replied, "Be steadfast and seek to draw near, for the one destined for Paradise will have his life sealed with the deeds of the people of Paradise, whatever deeds he may have done in between, and the one destined for the Fire will have his life sealed with the deeds of the people of the Fire, whatever deeds he may have done in between."Then the Messenger of Allah ﷺ gestured with his hands and cast them aside, saying, "Your Lord has finished with the servants. A group is in Paradise and a group is in the Blaze."Qutayba narrated to us, Bakr bin Mudar narrated to us from Abu Qubayl something similar.
حدثنا قتيبة حدثنا الليث عن أبي قبيل عن شفي بن ماتع عن عبد الله بن
خرج علينا رسول الله ﷺ وفي يده كتابان فقال أتدرون ما هذان الكتابان فقلنا لا يا رسول الله إلا أن تخبرنا فقال للذي في يده اليمنى هذا كتاب من رب العالمين فيه أسماء أهل الجنة وأسماء آبائهم وقبائلهم ثم أجمل على آخرهم فلا يزاد فيهم ولا ينقص منهم أبدا ثم قال للذي في شماله هذا كتاب من رب العالمين فيه أسماء أهل النار وأسماء آبائهم وقبائلهم ثم أجمل على آخرهم فلا يزاد فيهم ولا ينقص منهم أبدا فقال أصحابه ففيم العمل يا رسول الله إن كان أمر قد فرغ منه فقال سددوا وقاربوا فإن صاحب الجنة يختم له بعمل أهل الجنة وإن عمل أي عمل وإن صاحب النار يختم له بعمل أهل النار وإن عمل أي عمل ثم قال رسول الله ﷺ بيديه فنبذهما ثم قال فرغ ربكم من العباد فريق في الجنة وفريق في السعير حدثنا قتيبة حدثنا بكر بن مضر عن أبي قبيل نحوه
[Its isnad is hasan]. Nasai narrated it in Kubra, no. 11473, from Qutayba, and Ahmad, 2/167, from the hadith of Layth bin Saad, with the same wording.Abu Qabil is Huyayy bin Hani Maafiri.On this topic there is also a narration from Ibn Umar [Bazzar, Kashf Astar, 3/26, no. 2156].