According to the following Hadith, Bukhari claims that the prophet said deeds alone are decoupled from God’s mercy. Such that someone who does good deeds will not be guaranteed God’s mercy in the Hereafter.
Narrated Abu Huraira: I heard Allah’s Messenger (ﷺ) saying, “The good deeds of any person will not make him enter Paradise.” (i.e., None can enter Paradise through his good deeds.) They (the Prophet’s companions) said, ‘Not even you, O Allah’s Messenger (ﷺ)?’ He said, “Not even myself, unless Allah bestows His favor and mercy on me.” So be moderate in your religious deeds and do the deeds that are within your ability: and none of you should wish for death, for if he is a good doer, he may increase his good deeds, and if he is an evil doer, he may repent to Allah.”
Sahih al-Bukhari 5673
https://sunnah.com/bukhari:5673
How does this idea square against the verses of the Quran that came from the prophet himself, unlike the Hadith above that came from Bukhari? According to the Quran, good deeds and God’s mercy are coupled and not mutually exclusive. The following verse shows that God will admit them with His mercy because of one’s belief and righteous works.
45:30 As for those who believe and work righteousness, their Lord will admit them into His mercy. This is the great triumph.
7:43 We will remove all jealousy from their hearts. Rivers will flow beneath them, and they will say, “GOD be praised for guiding us. We could not possibly be guided, if it were not that GOD has guided us. The messengers of our Lord did bring the truth.” They will be called: “This is your Paradise. You have inherited it, in return for your works.”
The next verse indicates that God despite His mercy encompassing all things, He has specified it for those who lead a righteous life and give the Obligatory Charity (Zakat).
7:156 “And decree for us righteousness in this world, and in the Hereafter. We have repented to You. He said, “My retribution befalls whomever I will. But My mercy encompasses all things. However, I will specify it for those who (1) lead a righteous life, (2) give the obligatory charity (Zakat),* (3) believe in our revelations, and
All these verses show that our good deeds allow us to obtain God’s mercy. That God’s mercy is coupled with one’s belief and their good deeds.
2:25 Give good news to those who believe and lead a righteous life that they will have gardens with flowing streams. When provided with a provision of fruits therein, they will say, “This is what was provided for us previously.” Thus, they are given allegorical descriptions. They will have pure spouses therein, and they abide therein forever.