Ali bin Abu Talib reported,

We were attending a funeral at Baqi al-Gharqad when the Prophet ﷺ came to us. He sat down and we sat around him. He had a small staff with him, and he lowered his head and began scratching the ground with it. Then he said, "There is not one of you, not a single soul brought into being, whose place in Paradise or Hell has not already been written, and whose destiny as wretched or blessed has not already been recorded."A man said, "Messenger of Allah, should we then not rely on what has been written for us and abandon deeds? For whoever among us is of the people of blessedness will end up doing the deeds of the people of blessedness, and whoever among us is of the people of wretchedness will end up doing the deeds of the people of wretchedness."He replied, "As for the people of blessedness, they will be made to find ease in doing the deeds of blessedness, and as for the people of wretchedness, they will be made to find ease in doing the deeds of wretchedness."Then he recited, "As for he who gives and fears Allah and believes in the best reward" [Layl 92:5–6].

Bukhari 1362

Sahih

حدثنا عثمان قال حدثني جرير عن منصور عن سعد بن عبيدة عن أبي عبد الرحمن

عن علي رضي الله عنه قال

كنا في جنازة في بقيع الغرقد فأتانا النبي ﷺ فقعد وقعدنا حوله ومعه مخصرة فنكس فجعل ينكت بمخصرته ثم قال ما منكم من أحد ما من نفس منفوسة إلا كتب مكانها من الجنة والنار وإلا قد كتب شقية أو سعيدة فقال رجل يا رسول الله أفلا نتكل على كتابنا وندع العمل فمن كان منا من أهل السعادة فسيصير إلى عمل أهل السعادة وأما من كان منا من أهل الشقاوة فسيصير إلى عمل أهل الشقاوة قال أما أهل السعادة فييسرون لعمل السعادة وأما أهل الشقاوة فييسرون لعمل الشقاوة ثم قرأ {فأما من أعطى واتقى وصدق بالحسنى} الآية

البخاري 1362صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Funerals
Chapter
Exhortation of the narrator at the grave, and his companions sitting around him
Numbering
Darussalam 1362
Bukhari 1362